开发者

Coverity Prevent: how to handle "checked return" warning when I deliberately don't check the return?

开发者 https://www.devze.com 2023-02-12 05:57 出处:网络
As the title suggest, for example, in 85% of the situation, I\'d like to check the return code of foo(), but sometimes I really don\'t care about it, but this will raise Coverity warning.

As the title suggest, for example, in 85% of the situation, I'd like to check the return code of foo(), but sometimes I really don't care about it, but this will raise Coverity warning.

What's the best way to deal with this problem? Changing Cover开发者_开发问答ity settings doesn't count. :)


The correct way to suppress CHECKED_RETURN defect is to cast the return value you don't care about to a void. This has the additional advantage of making it clear to anyone reading the code that you don't care about return value, rather than that you forgot to check it.

0

精彩评论

暂无评论...
验证码 换一张
取 消