[Swan-dev] why there were useless assignments
Antony Antony
antony at phenome.org
Thu Feb 21 09:50:16 UTC 2019
Note: clang analyzer(scan-build) recommendation : (void)x
Q: How do I tell the static analyzer that I don't care about a specific dead store?
When the analyzer sees that a value stored into a variable is never used, it's going to produce a message similar to this one:
Value stored to 'x' is never read
You can use the (void)x; idiom to acknowledge that there is a dead store in
your code but you do not want it to be reported in the future.
On Wed, Feb 20, 2019 at 08:19:49PM -0500, Andrew Cagney wrote:
> Perhaps we need a function or macro called coverity_eat_this() that
> eats the values passed to it - I'm likely to continue writing code
> like what Hugh cited (and if I need to touch that code I'll likely
> restore the assignments). So what great security risk do unused
> values pose.
good idea. If you come up with a coverity_eat_this() keep in mind
USE_LABELED_IPSEC=no case I just explained. Also you may need
clag_eat_this()
I louder coverity would raise against (void)x; If coverity can eat that it
may work for some cases.
More information about the Swan-dev
mailing list