Menu

#660 GTK3V2MAIN: -Wmissing-field-initializers cleanup (cdraw.c macro fix + suppress the rest)

closed
nobody
None
11 hours ago
2 days ago
No

GTK3V2MAIN's -Wextra report-only CI job (compiler-warnings) carries 1067 -Wmissing-field-initializers findings. Root cause is a longstanding, deliberate codebase idiom: paramData_t/descData_t-family aggregate literals throughout app/bin's dialog control tables set only their leading fields (type/label/pointer) and rely on C's implicit zero-init for the rest. This isn't latent bugs, and a full conversion to designated initializers across ~1000 call sites is a large, real-regression-risk undertaking not worth doing in bulk.

Two changes:

  1. app/bin/cdraw.c has an actual macro layer other files don't: 33 "#define xNN { TYPE, LABEL, &target }" macros (descData_t positional literals), each expanded many times across large array literals, accounting for 111 of the 1067 warnings. Converted these 33 macro definitions to designated-initializer form (.type = ..., .label = ..., .valueP = ...) so every expansion site is fixed at the source. No behavior change -- omitted fields are still implicitly zero-initialized either way; this only changes how the compiler is told which fields are intentionally set. Verified: cdraw.c's contribution to -Wmissing-field-initializers drops from 144 to 33 (the remaining 33 are unrelated instances of other struct types in the same file, e.g. paramData_t/paramGroup_t, left to item 2 below).

  2. For the remaining ~956 instances (the general paramData_t/descData_t idiom, not cdraw.c's macro layer), added -Wno-missing-field-initializers to the project's real compile flags (PlatformSettings.cmake, both the UNIX and non-MSVC Windows branches) with a comment explaining the idiom, rather than -Werror-gating or bulk-rewriting them. Verified this suppresses the warning even under the CI compiler-warnings job's explicit -Wextra override (0 remaining, confirmed by rebuilding with the job's exact flags).

Kept out of any -Werror ratchet, per the project's own quality-improvement plan (GTK3V2MAIN only).

Verified: full local build clean (build-gtk3v2main), ctest 10/10 pass, AStyle-conformant (3.6.13, matching CI's pinned version), and a clean rebuild with CI's exact "-Wall -Wextra -Wno-unused-parameter" flags shows -Wmissing-field-initializers dropping from 1067 to 0 project-wide.

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB