c - 为什么 coverity 会为此发出警告?

标签 c coverity

我不确定为什么静态代码分析工具 Coverity 标记:

CID 40172 (#1 of 1): Parse warning (PW.INCOMPATIBLE_PARAM)
1. incompatible_param: argument of type "volatile mpls_RuntimeInfo_t *" is incompatible with parameter of type "void *"

对于这一行:

memset(&SW_RuntimeInfo[idx],0,sizeof(mpls_RuntimeInfo_t));

SW_RuntimeInfo 在全局范围内声明为 volatile static mpls_RuntimeInfo_t SW_RuntimeInfo[LABEL_T_CNT] = { 0 }; 时。
为什么它会升旗?我该如何解决?

最佳答案

它抛出警告是因为您将 volatile 指针传递给非 volatile 参数。如果您真的只想让警告消失,只需将您的参数转换为 void *。但也许您应该重新考虑您的变量是否应该是可变的,或者以不同的方式初始化它。

关于c - 为什么 coverity 会为此发出警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44701856/

相关文章:

c - TCP sendto 返回长度但服务器没有收到任何东西

c - 在 Windows 上使用 MinGW 调用 GCC 时如何将 Win32 指定为输出

C 字符串格式化等效项

c - C 中第一个堆栈中的项目无法到达第二个堆栈

angular - Coverity是否支持Angular2及以上版本?

android - 在 Android native 代码中挂起 TCP 套接字发送调用

c - MISRA 警告 12.4 : integer conversion resulted in truncation (negation operation)

c++ - 使用 sprintf/printf 使用 %ld 格式字符串而不是 %d 和 int 数据类型的效果

github - TravisCI/Coverity : Warning - No files were emitted