Skip to content

libobs: state the macOS conversions the sign-conversion ratchet now reports (#2625) - #2887

Closed
zackees wants to merge 1 commit into
masterfrom
fix/libobs-cocoa-sign-conversion
Closed

zackees wants to merge 1 commit into
masterfrom
fix/libobs-cocoa-sign-conversion

Conversation

@zackees

@zackees zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member

The libobs conversion ratchet (#2877, merged as ee3273d6) put -Wsign-conversion on the libobs targets for every Clang/GNU platform. Linux was replayed and clean, but AppleClang reaches the macOS-only libobs/obs-cocoa.m.h translation unit, and the first PR run after the merge failed on it (job 123326083017, Build 🧱 / Rust Tier 2 (macos-26)):

libobs/obs-cocoa.m.h:161:23: error: implicit conversion changes signedness: 'CFIndex' (aka 'long') to 'size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
libobs/obs-cocoa.m.h:727:26: error: implicit conversion changes signedness: 'unsigned int' to 'int' [-Werror,-Wsign-conversion]
libobs/obs-cocoa.m.h:836:53: error: implicit conversion loses integer precision: 'int' to 'UInt16' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
libobs/obs-cocoa.m.h:861:75: error: implicit conversion changes signedness: 'UniCharCount' (aka 'unsigned long') to 'CFIndex' (aka 'long') [-Werror,-Wsign-conversion]

Each conversion is now stated at its boundary, and the value each site had is kept:

  • dstr_reserve(&str, max_size) — CFStringGetMaximumSizeForEncoding() returns CFIndex; the assert(max_size > 0) above it is the proof that the size_t conversion is in range.
  • int button = key - 1 — obs_key_t's compatible type is unsigned int, so the subtraction was unsigned; the enum value is narrowed first, and the enclosing OBS_KEY_MOUSE1..OBS_KEY_MOUSE29 range bounds it.
  • both UCKeyTranslate() calls — ((alphaLock >> 8) & 0xFF) is int and fits the UInt16 key-action parameter exactly.
  • CFStringCreateWithCharactersNoCopy(NULL, buffer, length, …) — length is the UniCharCount that UCKeyTranslate() just wrote, bounded by the maxLength of 16.

No -Wno-*, no #pragma, no change to the pin. This is the macOS half of the same class the Linux replay of #2877 could not see; the run above is the RED evidence, and this PR's own macOS lane is the GREEN check.

Refs #2625

@zackees
zackees enabled auto-merge October 29, 2026 08:00

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — correct, and the four sites are exactly the ones the macOS job reported.

  • dstr_reserve(str, (size_t) max_size): CFStringGetMaximumSizeForEncoding() returns CFIndex; the assert(max_size > 0) immediately above is the in-range proof the size_t conversion needs. Value unchanged.
  • int button = (int) key - 1: narrowing the enum before the subtraction keeps the old unsigned-shaped result for the values that reach it, and the enclosing OBS_KEY_MOUSE1..OBS_KEY_MOUSE29 guard bounds button to 0..28, so 1 << button stays inside int.
  • (UInt16) ((alphaLock >> 8) & 0xFF): the mask already bounds the value, the cast only states it for UCKeyTranslate().
  • (CFIndex) length: length is what UCKeyTranslate() wrote, bounded by maxLength (16).

Style matches the C-style boundary casts already on master (libobs-opengl #2880), and there is no -Wno-*, no #pragma, and no change to the ratchet pin.

RED is master's Build 🧱 / Rust Tier 2 (macos-26) job 123326083017; the GREEN check is this PR's own macOS lane, which has not run yet (Fast Gate is still pending). Not queueing until it does.

@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Validation note: this PR is the macOS-only TU the Linux replay cannot see, so its own Rust Tier 2 (macos-26) lane is the check that matters. At the time of writing that lane had not reported on this PR (only Fast Gate and the Linux-side jobs ran), so the four casts are mechanically justified but not yet confirmed by an AppleClang compile. Whoever watches the next scheduled run should treat a remaining -Wsign-conversion/implicit-conversion diagnostic in libobs/obs-cocoa.m.h as mine to fix, not a new regression.

…ts (#2625)

#2877 enabled -Wsign-conversion on the libobs targets but could only replay
the Linux translation units. AppleClang reaches obs-cocoa.m.h, and the first
run after the merge failed there with four conversion diagnostics. State each
at its boundary: the CFIndex that the assert proves positive, the enum
subtraction that is unsigned until it is narrowed, the int key-action that
fits UInt16, and the UniCharCount handed to a CFIndex parameter.
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

This is now master breakage, not just a lane finding: the merge group for #2872 (40841144417, head 07340d52e) failed its Rust Tier 2 (macos-26) job on exactly these four libobs/obs-cocoa.m.h lines, so #2872 was ejected from the queue (UNMERGEABLE) for a red base. Landing this PR unblocks it and #2886 (stacked on this head).

One more diagnostic than the first head fixed: obs-cocoa.m.h:837, the int key code handed to UCKeyTranslate's UInt16 virtualKeyCode (-Wimplicit-int-conversion). INVALID_KEY is already rejected above the call, so the cast is safe. clang-format --dry-run --Werror clean on the file.

zackees added a commit that referenced this pull request Oct 29, 2026
-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + #2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so #2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Superseded by #2897, which carries this commit plus the enum -> int seam wave (#2896) in one PR.

The two are the same macOS Rust Tier 2 lane and it reports them in turn, so this PR cannot show a green lane on its own — the lane reaches obs-scene.c.h/obs-source-deinterlace.c.h straight after obs-cocoa.m.h and fails there. Keeping this one open would only produce a second red lane run for the same code; the single-line fix and its evidence are unchanged in #2897's first commit.

@zackees zackees closed this Oct 29, 2026
auto-merge was automatically disabled October 29, 2026 08:44

Pull request was closed

@zackees
zackees deleted the fix/libobs-cocoa-sign-conversion branch October 29, 2026 08:44
@zackees

zackees commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

The cocoa fix works — the lane now gets past obs-cocoa.m.h — but the same macOS run (40841202389, job 123343547757) stops on 19 more -Wsign-conversion diagnostics in four other libobs TUs:

file diagnostics
libobs/obs-scene.c.h 12 — obs_bounds_type, obs_scale_type, obs_blending_method, obs_blending_type, gs_color_space → int (lines 433, 460, 578, 579, 580, 649, 674 ×2, 676 ×2, 771, 808)
libobs/obs-source-deinterlace.c.h 5 — obs_deinterlace_mode, gs_color_space → int (237, 283, 285 ×2, 289)
libobs/obs-display.c.h 1 — gs_color_space → int (197)
libobs/obs-canvas.c.h 1 — video_format → int (328)

They are all the enum-to-int half of the same ratchet: the Rust ABI on the other side takes int, so each call site converts implicitly. This PR's four cocoa sites are fixed and no longer report; the rest is out of its scope, so I am not touching them from the coordinator side — it is the same AppleClang gap that let #2877 land green (its replay only covered Linux TUs). Tell me if you want these as a mechanical follow-up PR rather than folded in here.

zackees added a commit that referenced this pull request Oct 29, 2026
-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + #2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so #2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).
zackees added a commit that referenced this pull request Oct 29, 2026
-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + #2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so #2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).
zackees added a commit that referenced this pull request Oct 29, 2026
-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + #2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so #2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).
zackees added a commit that referenced this pull request Oct 29, 2026
-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + #2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so #2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In review to Done in obs-rust Multiview Oct 29, 2026
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
…#2879) (obs-rust#2900)

* libobs-opengl: state the macOS Cocoa conversions too (obs-rust#2879)

The first green attempt still failed: the same #ifdef-only blind spot hides
four more -Wsign-conversion diagnostics (CGLTexImageIOSurface2D takes GLsizei
widths from uint32_t texture fields) and two -Wfloat-conversion ones (CGSize
CGFloat dimensions into device_texture_create's uint32_t). State them at the
call; values unchanged.

* libobs: state the four macOS Cocoa conversions too (obs-rust#2879)

The libobs ratchet (obs-rust#2877) had the same Linux-only replay blind spot: the
macOS Tier 2 lane then reported CFIndex -> size_t (dstr_reserve), obs_key_t ->
int (mouse button index), int -> UInt16 (UCKeyTranslate key code) and
UniCharCount -> CFIndex (CFStringCreateWithCharactersNoCopy). State each at
the call; values unchanged.

* libobs: state the CoreAudio device-name length conversion (obs-rust#2879)

-Wsign-conversion on the macOS Tier 2 lane rejects strlen()'s size_t as the
CFIndex byte count; cast at the boundary.

* build(libobs): state the enum -> int seam conversions (obs-rust#2896)

-RED: `Rust Tier 2 (macos-26)` on `07340d52e` + obs-rust#2887's cocoa fix
(job 123343547757) reports 19 `-Werror,-Wsign-conversion` /
`-Wimplicit-int-conversion` diagnostics in the four Rust seam call
sites below: `enum video_format`, `obs_bounds_type`, `obs_scale_type`,
`obs_blending_method`, `obs_blending_type`, `gs_color_space` and
`obs_deinterlace_mode` passed to a helper the port declares with an
`int` parameter. AppleClang gives an all-non-negative enum an unsigned
underlying type; GCC and Linux clang keep `int`, so obs-rust#2877's replay of
the same TUs could not see them.

-GREEN: state the conversion at each call site, leaving the seam
signatures and the Rust `c_int` ABI unchanged. Two further sites of the
same class (obs_canvas_draw_technique()/reads_white_level() in
obs.c.h, the deinterlace mode-change call) are cast with them so the
next macOS wave does not re-report the group.

No Rust or cmocka change: no signature moved, and the casts are
behaviour-neutral (the values are enum members, not sentinels).

* build(libobs): state the source render-plan conversions (obs-rust#2896)

The next macOS Tier 2 wave after b43279b reports 19 more
'enum -> int' conversions, all in libobs/obs-source.c.h: the monitoring
type fed to obs_source_audio_place_outputs(), the async and sync render
plans' gs_color_space arguments, and src->format into
obs_source_frame_copy_plan().

AppleClang gives all-positive enums an unsigned underlying type; the
seam helpers take int (the Rust c_int ABI carries -1 sentinels), so each
call site is an implicit conversion visible only on Apple platforms.
Cast at each call site; signatures, Rust ABI and tests do not move.

* build(frontend): enable the sign-conversion warnings on the app target (obs-rust#2625)

* frontend: state the sign conversions the app target now reports (obs-rust#2625)

* build(libobs): state the source frame-copy seam conversions (obs-rust#2879)

-Wsign-conversion on the macOS lane rejects enum video_format and
enum video_range_type as the int parameters of the frame-copy helpers,
whose signatures are public API (obs-source-frame-copy.h) and stay int.
State the conversion at each of the seven call sites in obs-source.c.h.

* build(libobs): state the output and video conversions the macOS lane reports (obs-rust#2879)

The macOS Tier 2 lane on this branch stopped on the next wave after the
obs-source frame-copy seams: encoder-type slots, the CoreAudio caption
shift, the video copy-plan keys and the GPU encode format gate. Explicit
casts only; same values the compiler converted implicitly.

* build(libobs): state the hotkey name-map key conversion (obs-rust#2879)

* build(libobs): state the macOS path and CFString size conversions (obs-rust#2879)

* build(libobs): apply the local formatter to the platform-cocoa casts
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