前言
近期需要再次测一下代码,相比以前测试更有经验,也做了比较多的记录,正好将经验通过博客保留下来,为以后可能的QAC测试做准备。
安装导入分析代码
这部分在上一篇中已经详细介绍,具体请见,如有疑问可以留言。
【回眸】QAC软件指南——萌新使用篇http://t.csdnimg.cn/S6Zpe
前置经验
以前的导入头文件我选择提取全部头文件在一个文件夹里然后导入单个文件夹完成所有头文件的导入,但近期热心同事拿出shell脚本自动化添加头文件,从此找不到头文件的问题再也没出现,不仅如此,400多个头文件的路径在2分钟内就被水灵灵地加上了,实属科技改变生活。
QAC报错分析
根据同系列前一篇文章分析代码后,完成代码分析之后就进入了分析纠错环节
下面记录本次分析代码遇到的问题
app.c
1. 实在找不到原因,只好 disable
2.不允许多行注释
3.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
4.消息0857指出了一种情况,即在翻译单元内定义的宏数量超过了ISO:C90标准的最低要求1024个。消息0380指出了违反相应ISO:C99限制的代码,即4095个宏。
bootchain_handler.c
1.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
2.消息0857指出了一种情况,即在翻译单元内定义的宏数量超过了ISO:C90标准的最低要求1024个。消息0380指出了违反相应ISO:C99限制的代码,即4095个宏。
chagen.c
1.在注释里有特殊字符@,不符合规则.
2.不允许多行注释
3.不允许在头文件路径上有 / 字符
4.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
5.未定义LWIP_SOCKET 宏,经过查找,发现在lwipopts.h文件里#define LWIP_SOCKET 0 /**< \brief default is 1 */,但是在chagen.c 文件里引用的opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加LWIP_SOCKET = 0 ?
6.代码中使用int,违反了M3CM的"Avoid using basic numerical types directly"规则
7.#include "chargen.h"和"string.h"是多余的
8.图4的函数没有传入参数及返回值也没有外部连接,是多余的
ethernet.c
1.不允许多行注释
2.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
gnss_boot.c
1.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
gnss_boot_uart.c
1.在#include "..."指令中使用的文件名不符合ISO:C90标准最严格的可移植性要求。为了达到这种严格的一致性,包含文件名必须限制在最多6个字母字符、一个句点(.)和一个字母字符。这些字符应该全部大写或全部小写。
2.#include "stdio.h" 在#include "jupiter_debug.h"已经被包含.
3.#include "Uart.h"在#include "gnss_boot_uart.h"已经被包含
4.未命名的'struct'和'union'类型在迁移到C++时可能会导致可移植性问题。
5.大括号的使用不符合“exdented”风格
6.缩进 tab和空格混用导致进与文件中之前的缩进不一致错误
7.Use of basic type 'unsigned int'.避免使用基本类型“unsigned int”。
8.Use of basic type 'unsigned char'.避免使用基本类型“unsigned char”。
9.ISO:C90标准的最低要求(前6个字符内不唯一)内不唯一的情况,GNSS_Boot_UartStreamSize GNSS_Boot_UartTxInd等 不符合该条规定
10.匹配的大括号出现在同一行 - 建议使用正确的缩进。
11.文件范围静态变量“uart_rx_boot_buf_single”仅在一个函数中被访问,如果一个文件范围的静态变量仅在一个函数中被访问,那么它应该被声明为块范围的静态变量.
12.参数“size”和"status","count","ErrorId"从未被修改,因此可以用“const”限定符声明。
13.不允许使用显式或隐式的指针转换.
14.'memset' returns a value which is not being used.'memset'函数的返回值是无用的.
15.一个“unsigned short”类型的非恒定表达式正在被传递给更宽的无符号类型的函数参数,'unsigned int'。
16.Pointed to object has smaller size than the size_t argument存在数组越界的危险
17.有符号类型和无符号类型进行算术运算时会发生错误 if(Receivecnt < GNSS_Boot_GetUartStreamSize()-1)
18.timeoutCnt 是static uint16类型,但是却和int类型进行运算比较
19.图2的循环永远为真
20.图2 % 两边的类型不一样,会产生一个"signed int"
21.图2 == 两边的类型不一样,都将被提升为“signed int”以进行比较
22.图3 的flash_identifier 被定义为const 类型,过显式的类型转换去除了const限定符,因为这可能导致未定义行为,特别是如果试图通过非const指针修改原本应该是常量的数据。这违反了MISRA C标准中的规则11.4(强制),该规则要求在使用转换时必须确保转换不会去除任何类型限定符.
23.图4的!= 两边类型不一样,都将被提升为“signed int”以进行比较
24.图5的CombBaudData,baudrate_changed,host_ready,flash_ready被定义为const 类型,过显式的类型转换去除了const限定符,因为这可能导致未定义行为,特别是如果试图通过非const指针修改原本应该是常量的数据。这违反了MISRA C标准中的规则11.4(强制),该规则要求在使用转换时必须确保转换不会去除任何类型限定符.
25.图6的3个位运算的结果没有被显式地转换为它们的本质类型,可能存在未定义行为。
26.有非常多的 The operands of this relational operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.问题
httpserver-netconn.c
1.宏定义LWIP_NETCONN未定义。 在lwipopts.h文件里已经定义#define LWIP_NETCONN 0但是在httpserver-netconn.c文件里引用的opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加LWIP_NETCONN = 0 ?
httpd.c
1.宏定义LWIP_TCP未定义。 在lwipopts.h文件里已经定义#define LWIP_TCP 1 但是在httpd.c文件里引用的fs.h文件里包含opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_TCP = 1 ?
netbios.c
1.宏定义LWIP_UDP未定义。 在lwipopts.h文件里已经定义#define LWIP_UDP 1 但是在netbios.c文件里引用的opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_UDP = 1 ?
netio.c
1.宏定义LWIP_TCP未定义。 在lwipopts.h文件里已经定义#define LWIP_TCP 1 但是在netio.c文件里opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_TCP = 1 ?
2.netio.cd的代码在QAC中被识别成注释了
ping.c
1.宏定义LWIP_RAW未定义。 在lwipopts.h文件里已经定义#define LWIP_RAW 1 但是在ping.c文件里opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_RAW = 1 ?
rtp.c
1.宏定义LWIP_SOCKET未定义。 在lwipopts.h文件里已经定义#define LWIP_SOCKET 0 但是在rtp.c文件里opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_SOCKET = 0 ?
2.宏定义LWIP_IGMP未定义。 在opt.h文件里已经定义#define LWIP_IGMP 0 但是在rtp.c文件里已经包含opt.h,QAC未识别出,是否需要手动添加宏定义LWIP_IGMP = 0 ?
shell_i.c
1.宏定义LWIP_NETCONN未定义。 在lwipopts.h文件里已经定义#define LWIP_SOCKET 0 但是在rtp.c文件里opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_SOCKET = 0 ?

smtp.c
1.[Q] Cannot find 'lwip/opt.h' - Perhaps the appropriate search path was not given ?
2.宏定义LWIP_TCP未定义。 在lwipopts.h文件里已经定义#define LWIP_TCP 1 但是在smtp.c文件里opt.h包含lwipopts.h,QAC未识别出,是否需要手动添加宏定义LWIP_TCP = 1 ?
【备注:添加lwip/opt.h所在路径后上述2个错误消失】
App_Hssl.c
1.Address of automatic object exported to a pointer with linkage or wider scope. 直接修改全局变量WriteData.Address是不被允许的
2.Definite: Storing the address of an object in a pointer that has greater lifetime.使用未初始化的指针WriteDataValue
3.The operands of this equality operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.cnt和0比较,不应使用有符号和无符号类型之间的比较
4.The operands of this equality operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.cnt和2比较,不应使用有符号和无符号类型之间的比较.
5.Address of automatic object exported to a pointer with linkage or wider scope.直接修改全局变量ReadData.Address是不被允许的
6.Definite: Storing the address of an object in a pointer that has greater lifetime.不应使用未初始化的指针DataAddr
Aurix_Board_Uart.c
1.The array being initialized is not large enough to hold a terminating null byte for the string initializer.不应使用固定大小的数组来存储字符串字面量
static uint8 Send_Data_Start_PBuffer[12]={"P start send"};
static uint8 Send_Data_Start_SBuffer[12]={"S start send"};
static uint8 Send_Data_Start_PBuffer_Star[12]={"P send start"};
2.The operands of this equality operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.不应使用有符号和无符号类型之间的比较
Start_Flag == 0
Start_Flag==0
i<12
first_send == 0
P_Uart_Rec_Flg == 1
S_Uart_Rec_Flg == 1
i<12 i<12 i<12
Giga_Link_Uart.c
1.The operands of this equality operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.
不应使用有符号和无符号类型之间的比较first_send == 0
P_Giga_Link_Rec_Flg == 1
S_Giga_Link_Rec_Flg == 1
emc_core.c
1.The operands of this relational operator are expressions of different 'essential type' categories (unsigned and enum)不应使用不同类型的变量进行比较unsigned 和enum
i < EMC_MODULE_MAX
2.Implicit conversion: int to unsigned int.
不应将有符号整数赋值给无符号整数变量
(timeout % emc_module[i].period) == 0
memcpy(&emc_rx_buf[emc_rx_rd], buf, len);
3.The right-hand operand is non-constant and 'essentially signed' (int)but will be implicitly converted to an unsigned type (unsigned int)in this arithmetic operation.
不应将有符号整数与无符号整数进行运算
(timeout % emc_module[i].period) == 0
4.A non-constant expression of 'essentially signed' type (%1s) is being converted to unsigned type, 'unsigned int ' on assignment.
不应将有符号整数隐式转换为无符号整数
memcpy(&emc_rx_buf[emc_rx_rd], buf, len);
5.Possible: Pointed to object has smaller size than the size_t argument.不应使用memset函数来初始化数组,特别是当n大于数组的大小时
memcpy(&emc_rx_buf[emc_rx_rd], buf, len);
emc_event.c
1.Type of 'case' label expression is not consistent with type of controlling expression in 'switch' statement.在switch语句中,case标签的类型必须与switch表达式的类型相同
MESSAGE_HEART_BEAT
MESSAGE_EVENT
MESSAGE_SYSTEM_INFO_REP
fifo.c
1.[I] Destination and source objects may have incompatible types.
在使用这些指针之前没有进行空指针检查
memcpy(&fifo_ptr->buff[fifo_ptr->ptr_in], data, fifo_ptr->size);
2.A non-constant expression of 'essentially signed' type (int) is being converted to unsigned type, 'unsigned int' on assignment.
不应将有符号整数隐式转换为无符号整数
memcpy(&fifo_ptr->buff[fifo_ptr->ptr_in], data, fifo_ptr->size);
memcpy(data,&fifo_ptr->buff[fifo_ptr->ptr_out],fifo_ptr->size);
3.Implicit conversion: int to unsigned int.
函数参数类型不匹配fifo_ptr->size
emc_1pps.c
1.The operands of this relational operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.比较有符号和无符号字符时,应确保类型匹配
emc_1pps_high_cnt < 3
emc_1pps_low_cnt < 3
emc_1pps_low_cnt > 0
emc_1pps_high_cnt > 0
emc_1pps_high_cnt > 0
emc_1pps_low_cnt > 0
2.The value of this 'if' controlling expression is always 'true'. if条件永远成立
if (emc_1pps_params.report)
emc_USS.c
1.The operands of this relational operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.
比较有符号和无符号整数时,可能导致意外的结果
i < ALL_SENSORS
emc_adc.c
1.A non-constant expression of 'essentially signed' type (unsigned int) is being converted to unsigned type, ' unsigned char ' on assignment.类型不匹配比较易出错
temp = channel/8;
adc_channel = channel%8;
EMC_COUNT_ADC[channel] >= MAX_ADC_ERROR_CNT)
channel].err_cnt < MAX_ADC_ERROR_CNT
adc_data[channel].err_cnt < MAX_ADC_ERROR_CNT
8 != uss_clearVoutErr
2.Type of 'case' label expression is not consistent with type of controlling expression in 'switch' statement.在switch语句中使用不匹配的常量类型
switch(temp)
{
case 0
3.Apparent: Using value of uninitialized automatic object 'adc_channel' and 'adc_group'.
变量未初始化就使用
emc_aurix_orin_uart.c
1.The value of this 'if' controlling expression is always 'true'.if条件永远成立
if (aurix_orin_uart_params.report)
emc_boot_chain.c
1.The operands of this arithmetic operator are of different 'essential signedness' but will generate a result of type 'signed int'.
有符号和无符号整数的混合运算可能导致意外的结果
bch_get_active_bootchain_data() + 0x41
emc_can.c
1.The operands of this relational operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.类型不同的比较可能导致意外的结果
channel <MAX_CAN_BUS
i < MAX_CAN_BUS
Can_17_McmCanConf_CanHardwareObject_CanHardwareObject_6+i
emc_d9s.c
1.The operands of this relational operator are of different 'essential signedness' but will both be promoted to 'signed int' for comparison.类型不同的比较可能导致意外的结果
remain_len <= EMC_D9S_MSG_LEN
i< EMC_D9S_MSG_LEN
SYNC2 == data[i+1]
MSG_ID == data[i+3]
(i+CN0_OFFSET) < EMC_D9S_MSG_LEN
1 == uart_rx_finish
2.Apparent: Pointed to object has smaller size than the size_t argument.数组越界访问
memcpy(&uart_rx_buf_Msg[Receivecnt],&uart_rx_temp_buf[0],remain_len);
memcpy(&uart_rx_buf_Msg[Receivecnt],&uart_rx_temp_buf[0],Stream_RxDataSize);
3.Apparent: Maximum number of characters to be read/written is larger than the target buffer size.数组越界访问
memcpy(&uart_rx_buf_Msg[Receivecnt],&uart_rx_temp_buf[0],remain_len);
emc_eru.c
1.The value of this 'if' controlling expression is always 'true'.if条件永远成立
if (emc_eru_params.report)
emc_eth_gpio.c
1.Implicit conversion: int to unsigned int.函数返回值类型不匹配
timeout % eth_gpio[i].period
2.The right-hand operand is non-constant and 'essentially signed' (int) but will be implicitly converted to an unsigned type (unsigned int) in this arithmetic operation.int 和unsigned int的运算可能会导致溢出
timeout % eth_gpio[i].period
emc_giga_link.c
1.The value of this 'if' controlling expression is always 'true'. if条件句永远为真
if (giga_link_params.report)
emc_ina226.c
1.The value of this 'if' controlling expression is always 'true'. if条件句永远为真
if (ina_params.report)
emc_pwm_cpu.c
1.The result of this logical operation is always 'true'.
g_period_flg==1
g_period_flg==1
g_period_flg==1
2.This code is unreachable.
return TRUE;
emc_uart.c
1.The value of this 'if' controlling expression is always 'true'. if条件句永远为真
if (uart_params.report)
emc_w25q16.c
1.The value of this 'if' controlling expression is always 'true'. if条件句永远为真
if (emc_w25q16_params.report)
jupiter_debug.c
1.[C] Initialization of locally declared 'extern print_f' is illegal.
void print_f(const char *p_frm, ...)
test_jupiter_loopback.c
1.This loop will never be executed more than once.循环不超过1次
for( i = 0; i < ( sizeof(jupiter_m88q5152loopback) / sizeof(t_m88q5152_pvlan_cfg) ); i++ ){
EWTS5G.c
1.Definite: Using value of uninitialized automatic object 'spi_rx'.未初始化的变量spi_rx
return spi_rx[2] >> 6;
Adc_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数名error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的3个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
AscLin_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数
IFX_INTERRUPT(ASCLIN1TX_ISR, 0, IRQ_ASCLIN1_TX_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的多个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
Can_17_McmCan_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数
IFX_INTERRUPT(ASCLIN1TX_ISR, 0, IRQ_ASCLIN1_TX_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的多个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
Eru_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数
IFX_INTERRUPT(ASCLIN1TX_ISR, 0, IRQ_ASCLIN1_TX_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的多个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
Hssl_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数
IFX_INTERRUPT(ASCLIN1TX_ISR, 0, IRQ_ASCLIN1_TX_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的多个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
Hssl_Irq.c
1.[C] Two parameters have been declared with the same name 'error_recovery_inserted_identifier'.重复的参数
IFX_INTERRUPT(ASCLIN1TX_ISR, 0, IRQ_ASCLIN1_TX_PRIO)
2.Inserted ' , ' token in an attempt to continue parsing.缺少逗号
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO)
3.Inserted 'error_recovery_inserted_identifier' token in an attempt to continue parsing.
4.[U] More than one definition of ' IFX_INTERRUPT ' (with external linkage).在代码中存在多个具有外部链接的 'IFX_INTERRUPT' 定义
IFX_INTERRUPT(ADC1SR0_ISR, 0, IRQ_ADC1_SR0_PRIO)
5.[S] Expected:error_recovery_inserted_identifier
IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).
代码中的多个中断都有7 8 9 及错误,集中在IFX_INTERRUPT(ADC0SR0_ISR, 0, IRQ_ADC0_SR0_PRIO).这类语句中.
IoHwAb_I2c.c
1.This loop, if entered, will never terminate.如果进入循环,不会跳出循环
while(I2c1_state == 0xFF)
while(I2c0_state == 0xFF)
while(I2c1_state == 0xFF)
while(I2c0_state == 0xFF)
IoHwAb_Uart.c
1.[U] Macro identifier does not differ from other macro identifier(s) (e.g. 'UART_STOP_SEC_VAR_CLEARED_ASIL_B_LOCAL_8') within the specified number of significant characters.在C语言中,标识符(如变量名、函数名等)通常遵循以下规则:
标识符可以包含字母(大写和小写)、数字和下划线。
标识符的第一个字符必须是字母或下划线。
标识符的长度没有硬性限制,但通常建议不要超过一定的长度,例如31个字符。
在某些编译器或系统中,标识符可能对大小写敏感。
UART_STOP_SEC_VAR_CLEARED_ASIL_B_LOCAL_32宏定义与UART_STOP_SEC_VAR_CLEARED_ASIL_B_LOCAL_8相似且不符合标识符命名规则
TJA1145a.c
1.Definite: Passing address of uninitialized object 'rx' to a function parameter declared as a pointer to const.未初始化的rx
(uint8 *)&rx
2.Definite: Using value of uninitialized automatic object 'rx'.使用未初始化的变量rx
value = rx & 0xFF;
W25QXX.c
1.Definite: Using value of uninitialized automatic object 'rx'.使用未初始化的变量rx_data
return rx_data[1]
jedec_id = (rx_data[1] << 16) | (rx_data[2] << 8) | rx_data[3];等
2.Use of memory allocation or deallocation function: calloc, malloc, realloc or free.
malloc(sizeof(uint8) * (len+4))
free(spi_tx);没有包含正确的头文件
CanXcp.c
1.[U] Macro identifier does not differ from other macro identifier(s) (e.g. 'CanXcp_SilentBswCheckErrorReturnVoid') within the specified number of significant characters.
在C语言中,标识符(如变量名、函数名等)通常遵循以下规则:
标识符可以包含字母(大写和小写)、数字和下划线。
标识符的第一个字符必须是字母或下划线。
标识符的长度没有硬性限制,但通常建议不要超过一定的长度,例如31个字符。
在某些编译器或系统中,标识符可能对大小写敏感。
CanXcp_SilentBswCheckErrorReturnValue与CanXcp_SilentBswCheckErrorReturnVoid相似且不符合命名规则
2.This loop will never be executed more than once.循环可能不超过1次
for( i = 0u; i < CANXCP_NUMBER_OF_CHANNELS; i++ )
代码中有3个这样的循环
Xcp.c
1.This loop will never be executed more than once.循环可能不超过1次
for( XcpChannel = 0u; XcpChannel < XCP_NUMBER_OF_CHANNELS; XcpChannel++ )
代码中有5个这样的循环
crc.c
1.Definite: Positive integer value truncated by implicit conversion to a smaller unsigned type.
byte = byte << 1;
2.Definite: Negative value implicitly converted to an unsigned type. 对无符号类型的变量进行运算可能导致未知的错误
srcBuf[0] & (1 << i)
3.Definite: Right hand operand of shift operator is negative or too large.移位操作符的右操作数为负数或过大
tmp[0] |= 1 << (15 - i)
version.c
1.Possible: Pointed to object has smaller size than the size_t argument.可能存在数组越界
hw_phase_id[i].phase_id
memcpy(hwPhaseID,hw_phase_id[i].phase_id,strlen(hw_phase_id[i].phase_id));
更新完毕-最后更新日期:2024/09/30