ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CWE:通病总结

2021-12-16 20:03:08  阅读:220  来源: 互联网

标签:总结 cwe int 通病 unsigned 012 scope CWE reduced


文章目录

网站

https://cwe.mitre.org/data/definitions/686.html

398

风格问题,如果一个局部变量,可以放在一个更小的区域,而且满足使用,最好是将作用域缩小。但是需要注意不要搞错。检查工具有点时候,检查有问题。
[STYLE] (cwe=398, variableScope):
The scope of the variable ‘left’ can be reduced., The scope of the variable ‘left’ can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for ‘i’ can be reduced:\012
void f(int x)\012
{
\012 int i = 0;
\012 if (x) {
\012 // it’s safe to move ‘int i = 0;’ here
\012 for (int n = 0; n < 10; ++n) {
\012 // it is possible but not safe to move ‘int i = 0;’ here
\012 do_something(&i);
\012 }
\012 }
\012}
\012When you see this message it is always safe to reduce the variable scope 1 level.

686

可移植性,非法打印参数类型。%x,需要一个无符号数,但是给的确实有符号长整型。
[PORTABILITY] (cwe=686, invalidPrintfArgType_uint): %x in format string (no. 1) requires ‘unsigned int’ but the argument type is ‘uintptr_t {aka unsigned long}’., %x in format string (no. 1) requires ‘unsigned int’ but the argument type is ‘uintptr_t {aka unsigned long}’.

标签:总结,cwe,int,通病,unsigned,012,scope,CWE,reduced
来源: https://blog.csdn.net/qq_36428903/article/details/121965667

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有