fix: 内核告警修复
【背景】 经代码扫描工具检测,内核代码中存在 可以修复的告警 【修改方案】 1.将单语句的if, while等加上括号 2.将C语言风格的类型转换变为C++风格 【影响】 对现有的产品编译不会有影响。 Signed-off-by: yinjiaming <yinjiaming@huawei.com> Change-Id: I7d4a04a8904abb3c33e843049bf15f4386d3efd8
This commit is contained in:
@@ -49,10 +49,10 @@ static void *Xmalloc(unsigned n)
|
||||
|
||||
static int Compare(const void *pa, const void *pb)
|
||||
{
|
||||
if (*(int *)pa < *(int *)pb) {
|
||||
if (*static_cast<int *>(const_cast<void *>(pa)) < *static_cast<int *>(const_cast<void *>(pb))) {
|
||||
return -1;
|
||||
}
|
||||
if (*(int *)pa > *(int *)pb) {
|
||||
if (*static_cast<int *>(const_cast<void *>(pa)) > *static_cast<int *>(const_cast<void *>(pb))) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -66,12 +66,14 @@ static void Action(const void *nodep, VISIT which, int depth)
|
||||
case preorder:
|
||||
break;
|
||||
case postorder:
|
||||
datap = *(int **)nodep;
|
||||
datap = *static_cast<int **>(const_cast<void *>(nodep));
|
||||
break;
|
||||
case endorder:
|
||||
break;
|
||||
case leaf:
|
||||
datap = *(int **)nodep;
|
||||
datap = *static_cast<int **>(const_cast<void *>(nodep));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +88,7 @@ static UINT32 TestCase(VOID)
|
||||
for (i = 0; i < 12; i++) {
|
||||
ptr = (int *)Xmalloc(sizeof(int));
|
||||
*ptr = rand() & 0xff;
|
||||
val = tsearch((void *)ptr, &g_root, Compare);
|
||||
val = tsearch(static_cast<void *>(ptr), &g_root, Compare);
|
||||
if (val == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
} else if ((*(int **)val) != ptr) {
|
||||
|
||||
Reference in New Issue
Block a user