Yo Hal! On Sun, 05 Feb 2023 17:38:49 -0800 Hal Murray via devel <devel@ntpsec.org> wrote:
> 1439 default: { > 1440 /* There should be a way for the compiler to > check this. */ 1441 bool once =3D false; > >>> CID 435753: Possible Control flow issues (DEADCODE) > >>> Execution cannot reach this statement: "return;". =20 > 1442 if (once) return; /* Avoid log > file DDoS */ > > That's some of my new code. I figured, since a new coverity issue. > In this case, I'm switching on a enum and have handled all the cases > so the default "can't happen". Sadly some compilers will always complain if there is no default. So I always add a default. > How do I get the compiler to tell me if I missed an option on a > switch statement? From "man gcc": -Wswitch Warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that enumeration. Or the similar -Wswitch-enum > Of course, the data might get mashed, so the other question is: > How do I get coverty to not complain about this code? // coverity[var_deref_model] That will ignore a var_deref_model message on the net line. Grep the ntpsec sources, it is used a lot. Maybe over used. RGDS GARY --------------------------------------------------------------------------- Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703 g...@rellim.com Tel:+1 541 382 8588 Veritas liberabit vos. -- Quid est veritas? "If you can't measure it, you can't improve it." - Lord Kelvin
pgpMWHqnxVBoL.pgp
Description: OpenPGP digital signature
_______________________________________________ devel mailing list devel@ntpsec.org https://lists.ntpsec.org/mailman/listinfo/devel