Skip to content

build(text-freetype2): compile the plugin's target with the conversion warnings enabled (#2625) - #2755

Merged
zackees merged 2 commits into
masterfrom
infra/2625-conversion-text-freetype2
Oct 28, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2625-conversion-text-freetype2

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

Slice of #2625 (drop the conversion pins). One plugin, as the issue's acceptance criteria require: the pins cannot be deleted per directory.

RED — 37cb9d607

plugins/text-freetype2/CMakeLists.txt enables -Wconversion, -Wsign-conversion and -Wfloat-conversion on the text-freetype2 target, so the conversions this plugin still hides become diagnostics. Replaying its Tier 2 C translation units from the build tree's compile database with the groups added reports 17 diagnostics (11 -Wsign-conversion, 6 -Wconversion), all expanding from text-functionality.c.h:

line conversion
:111, :160, :284, :294, :308, :412 wchar_t text code unit passed as FT_ULong to FT_Get_Char_Index
:113, :419 (reported at the src_glyph macro, text-freetype2.h:26) FT_Pos advance added to a uint32_t width
:179 (x2), :180 (x2) uint32_t/int32_t glyph geometry mixed into the float baseline arithmetic
:228, :229 uint32_t bitmap dimension stored into the int32_t glyph_info field
:264 int bitmap pitch multiplied into a uint32_t row offset
:422 FT_Pos advance shifted into a uint32_t width

GREEN — 43c6e64ec

Every fix is an explicit cast at the call site, and each one keeps the value the code already computed: the text is a wchar_t string, so its code units are non-negative before they become a FreeType char index; a glyph advance (FT_Pos) is never negative; the bitmap pitch is already taken as abs(); and a rendered bitmap dimension is far inside int32_t. The two midline conversions (:179/:180) now share one computed float baseline, so the comparison and the store use the same value the expression already produced. No #pragma, no per-file -Wno-*, and the global pins are untouched.

Evidence, on this checkout's Tier 2 build volume:

  • the same replay of the plugin's 14 C translation units with the three groups added: 0 findings, exit 0;
  • ninja text-freetype2 in that tree re-configures, compiles text-freetype2.core+.h.c with -Wconversion -Wsign-conversion -Wfloat-conversion -Werror and links — clean (the compile lines are real, not a compiler-cache hit);
  • clang-format --dry-run --Werror, gersemi -c and ./lint clean.

No docs/features.md line: build tooling only.

Refs #2625

…ersion groups enabled

Enables -Wconversion, -Wsign-conversion and -Wfloat-conversion on the
text-freetype2 target only, so the conversions this plugin still hides become
diagnostics. Replaying its Tier 2 C translation units from the build tree's
compile database with the groups enabled reports 17 diagnostics, all in
text-functionality.c.h (plus the src_glyph macro at text-freetype2.h:26):

  :111 :160  wchar_t from the text buffer passed as FT_ULong to FT_Get_Char_Index
  :113       FT_Pos advance into the uint32_t word width
  :179 :180  uint32_t/int32_t glyph geometry mixed into the float baseline arithmetic
  :228 :229  uint32_t glyph width/height stored into the int32_t glyph_info fields
  :264       int bitmap pitch multiplied into a uint32_t row offset
  :284 :294 :308  wchar_t glyph-cache callback argument passed as FT_ULong
  :412 :419 :422  same in get_ft2_text_width, and the advance into uint32_t

Refs #2625
Each cast keeps the value the code already computed: the text buffer is a
wchar_t string, so its code units are non-negative before they become the
FT_ULong a FreeType char index takes; a glyph advance (FT_Pos) is never
negative; a bitmap pitch is taken as abs() and a row offset cannot exceed
the atlas; and the glyph_info width/height fields hold a rendered bitmap
dimension, which is far inside int32_t.

The two midline conversions (:179/:180) share one computed float baseline,
so the comparison and the store use the same value the expression already
produced.

Replaying the plugin's Tier 2 C translation units with the three groups
enabled now reports zero diagnostics, and `ninja text-freetype2` in that
tree compiles with -Werror on. clang-format --dry-run --Werror and
gersemi -c are clean.

Refs #2625
@zackees
zackees added this pull request to the merge queue Oct 28, 2026
Merged via the queue into master with commit 310683a Oct 28, 2026
39 checks passed
@zackees
zackees deleted the infra/2625-conversion-text-freetype2 branch October 28, 2026 09:30
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
… ratchets (obs-rust#2625) (obs-rust#2789)

* fix(text-freetype2): cast the two size_t arguments the macOS/Windows build flags (obs-rust#2625)

obs-rust#2755 enabled -Wconversion/-Wsign-conversion on the text-freetype2 target,
but the Linux lane never compiles find-font.c.h: the nix unity group uses
find-font-unix.c.h, and find-font.c.h is only in the windows+ and macos+
groups. So the ratchet looked clean on Linux while the release lane's
macOS and Windows app builds failed:

  find-font.c.h:58:30: da_resize(font_list, count) - int -> size_t
  find-font.c.h:218:31: da_reserve(sizes, face->num_fixed_sizes) -
                        FT_Int -> size_t

Both casts keep the value the code already passed (the implicit conversion
happened inside da_resize/da_reserve). Red run 40684548610 (arm64 job
122803565099) is the evidence; reproduced locally by adding the find-font
unity group to the Linux target for one build:

  find-font.c.h:58  conversion to size_t from int
  find-font.c.h:218 conversion to size_t from FT_Int
  -> after the casts: neither diagnostic (only the shadow error the
     temporary double include provokes on Linux, absent on the real
     Windows/macOS build).

Refs obs-rust#2625

* fix(image-source): compare the slide time to zero instead of negating a float (obs-rust#2625)

obs-rust#2753 enabled -Wfloat-conversion on the image-source target. GCC does not
flag it, so the slice was green on Linux PR CI, but AppleClang reports it
in the release lane's macOS app build:

  obs-slideshow.c.h:983 implicit conversion turns floating-point number
  into integer: 'float' to 'bool' [-Werror,-Wfloat-conversion]

  if (!ss->transition || !ss->slide_time)

'!x' on a float is 'x == 0.0f' (NaN was already false), so the comparison
is spelled out and the value tested is unchanged. Same verify-only run
40689520273 (arm64 job 122820591980) is the RED evidence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant