Commit c472c05
committed
git-compat-util: suppress Coverity false positives from CONST_OUTPARAM
The CONST_OUTPARAM macro uses a dead ternary branch for
compile-time type checking:
(0 ? (*(out) = (in)), (out)) : (out))
The write *(out) = (in) never executes (guarded by "0 ?"), but
it ensures that *out and in have compatible types. When
skip_prefix(p, "literal", &p) expands, the third argument to
skip_prefix_impl contains this dead write to p while the first
argument reads p. Coverity's EVALUATION_ORDER checker does not
eliminate the dead branch and flags this as an unsequenced
read/write of the same variable, producing 122 false positives
across the codebase.
Model files cannot suppress this because the issue is in macro
expansion, which happens before Coverity's function-level
modeling. An earlier attempt to model skip_prefix_impl() in
the Coverity model file had no effect because Coverity inlines
the static inline function rather than using the model.
Simplify CONST_OUTPARAM to just (out) under __COVERITY__,
dropping the type-checking branch that confuses the checker. The
type safety is preserved for real builds.
Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 6b70aed commit c472c05
1 file changed
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
502 | 512 | | |
503 | 513 | | |
| 514 | + | |
504 | 515 | | |
505 | 516 | | |
506 | 517 | | |
| |||
0 commit comments