Enable additional compiler warning flags #100

Open
opened 2026-03-04 19:23:53 +00:00 by jabber.developer2 · 0 comments
Collaborator

Context

As part of the compiler flags hardening work (PR #98), a batch of low-impact flags was added

Already enabled: -Wundef, -Wfloat-equal, -Wredundant-decls, -Walloc-zero, -Warray-bounds=2

The flags below were evaluated but deferred due to the volume of changes required or false positives.


Deferred flags

# Flag Issue Effort Notes
1 -Wold-style-definition 24 K&R-style definitions (void f()void f(void)) Small Mechanical, touches many files
2 -Wshadow ~8 errors in stanza.c — locals shadow outer variables (child, text) Medium Rename variables in nested blocks
3 -Wjump-misses-init goto jumps over initialized variables in omemo.c Medium Partially fixed in PR #98; some cases remain
4 -Wmissing-prototypes Internal functions in xmpp/ not static and without header prototypes (blocking.c, presence.c, iq.c, connection.c, message.c) Medium-Large Each function: make static or add to .h
5 -Wformat-truncation=2 False positive in cmd_funcs.c:170-175 — truncation already handled at runtime Small Needs pragma or refactor; level 1 (via -Wall) works fine
6 -Wswitch-enum Fires on external library enums (libstrophe, GLib) where not all values are meaningful Large (noise) Hundreds of default: already handle these; impractical
7 -Wwrite-strings String literals → const char[] causes cascading errors across many function signatures Large Separate PR recommended
8 -Wconversion Implicit type conversions; very high noise with GLib types Large Separate PR recommended

Plan

Phase Flags Scope
1 — Low-hanging fruit -Wold-style-definition, -Wshadow ~32 mechanical fixes
2 — Medium effort -Wjump-misses-init, -Wmissing-prototypes, -Wformat-truncation=2 Audit xmpp/ internals, finish omemo.c, one pragma
3 — Separate PRs -Wwrite-strings, -Wconversion Large scope, many signature changes
Skip / revisit -Wswitch-enum Too noisy with external enums

Each flag should be added as a separate commit together with the fixes for affected code.

### Context As part of the compiler flags hardening work (PR #98), a batch of low-impact flags was added **Already enabled:** `-Wundef`, `-Wfloat-equal`, `-Wredundant-decls`, `-Walloc-zero`, `-Warray-bounds=2` The flags below were evaluated but deferred due to the volume of changes required or false positives. --- ### Deferred flags | # | Flag | Issue | Effort | Notes | |---|------|-------|--------|-------| | 1 | `-Wold-style-definition` | 24 K&R-style definitions (`void f()` → `void f(void)`) | Small | Mechanical, touches many files | | 2 | `-Wshadow` | ~8 errors in `stanza.c` — locals shadow outer variables (`child`, `text`) | Medium | Rename variables in nested blocks | | 3 | `-Wjump-misses-init` | `goto` jumps over initialized variables in `omemo.c` | Medium | Partially fixed in PR #98; some cases remain | | 4 | `-Wmissing-prototypes` | Internal functions in `xmpp/` not `static` and without header prototypes (`blocking.c`, `presence.c`, `iq.c`, `connection.c`, `message.c`) | Medium-Large | Each function: make `static` or add to `.h` | | 5 | `-Wformat-truncation=2` | False positive in `cmd_funcs.c:170-175` — truncation already handled at runtime | Small | Needs pragma or refactor; level 1 (via `-Wall`) works fine | | 6 | `-Wswitch-enum` | Fires on external library enums (libstrophe, GLib) where not all values are meaningful | Large (noise) | Hundreds of `default:` already handle these; impractical | | 7 | `-Wwrite-strings` | String literals → `const char[]` causes cascading errors across many function signatures | Large | Separate PR recommended | | 8 | `-Wconversion` | Implicit type conversions; very high noise with GLib types | Large | Separate PR recommended | --- ### Plan | Phase | Flags | Scope | |-------|-------|-------| | 1 — Low-hanging fruit | `-Wold-style-definition`, `-Wshadow` | ~32 mechanical fixes | | 2 — Medium effort | `-Wjump-misses-init`, `-Wmissing-prototypes`, `-Wformat-truncation=2` | Audit `xmpp/` internals, finish `omemo.c`, one pragma | | 3 — Separate PRs | `-Wwrite-strings`, `-Wconversion` | Large scope, many signature changes | | Skip / revisit | `-Wswitch-enum` | Too noisy with external enums | Each flag should be added as a separate commit together with the fixes for affected code.
jabber.developer2 added the
Kind/Enhancement
Priority
Low
4
labels 2026-03-04 19:23:53 +00:00
jabber.developer2 added this to the Plans (2025-2026) project 2026-03-04 19:23:53 +00:00
jabber.developer2 changed title from Enable additional compiler warning flags: `-Wshadow`, `-Wwrite-strings`, `-Wjump-misses-init` and others to Enable additional compiler warning flags 2026-03-04 19:24:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devs/cproof#100
No description provided.