Repository navigation
build(text-freetype2): compile the plugin's target with the conversion warnings enabled (#2625) - #2755
Merged
Conversation
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice of #2625 (drop the conversion pins). One plugin, as the issue's acceptance criteria require: the pins cannot be deleted per directory.
RED —
37cb9d607plugins/text-freetype2/CMakeLists.txtenables-Wconversion,-Wsign-conversionand-Wfloat-conversionon thetext-freetype2target, 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 fromtext-functionality.c.h::111,:160,:284,:294,:308,:412wchar_ttext code unit passed asFT_ULongtoFT_Get_Char_Index:113,:419(reported at thesrc_glyphmacro,text-freetype2.h:26)FT_Posadvance added to auint32_twidth:179(x2),:180(x2)uint32_t/int32_tglyph geometry mixed into the float baseline arithmetic:228,:229uint32_tbitmap dimension stored into theint32_tglyph_infofield:264intbitmap pitch multiplied into auint32_trow offset:422FT_Posadvance shifted into auint32_twidthGREEN —
43c6e64ecEvery fix is an explicit cast at the call site, and each one keeps the value the code already computed: the text is a
wchar_tstring, 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 asabs(); and a rendered bitmap dimension is far insideint32_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:
ninja text-freetype2in that tree re-configures, compilestext-freetype2.core+.h.cwith-Wconversion -Wsign-conversion -Wfloat-conversion -Werrorand links — clean (the compile lines are real, not a compiler-cache hit);clang-format --dry-run --Werror,gersemi -cand./lintclean.No
docs/features.mdline: build tooling only.Refs #2625