Coverity Prevent:如何处理“已检查退货”当我故意不检查退货时发出警告?
正如标题所暗示的,例如,在 85% 的情况下,我想检查 foo() 的返回码,但有时我真的不关心它,但这会引发 Coverity 警告。
处理这个问题的最佳方法是什么? 更改 Coverity 设置无效。 :)
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 Coverity settings doesn't count. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抑制 CHECKED_RETURN 缺陷的正确方法是将您不关心的返回值转换为 void。这样做的另一个好处是,可以让任何阅读代码的人清楚地知道您不关心返回值,而不是您忘记检查它。
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.