【回眸】QAC软件指南——错误分析篇(完整版)

前言

近期需要再次测一下代码,相比以前测试更有经验,也做了比较多的记录,正好将经验通过博客保留下来,为以后可能的QAC测试做准备。

安装导入分析代码

这部分在上一篇中已经详细介绍,具体请见,如有疑问可以留言。

【回眸】QAC软件指南——萌新使用篇icon-default.png?t=O83Ahttp://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 

1、 QAC介绍和使用说明 其他的功能概括 1、提供一种可量化措施的代码度量值属性:33基于功能 32基于文件和4个项目级别 2、功能结构关系图,以提供控制流动洞察 3、展示全局调用函数的关系图引用和文件树结构 4、提供统计分析对代码质量的全面评估 5、跨模块分析能力(CMA)、分析递归功能和全局标识符的各种问题 6、简化的旧代码修改的设置基准模块 Source..c文件通过分析工具生成3种文件source.c.i、source.c.met、source.c.err。source.c.i文件可以直接生成报告文件,.met、.err这两个文件可以分析出功能结构、关系、特征标准、报告或者进行跨模块分析,对于跨模块分析和剖析器分析需要进行配置,source.c.met、source.c.err、配置文件可以在信息浏览器中显示 2、 规划 2.1、自动生成文件及参数说明 生成自动文档步骤: 1、从文件菜单中选者Auto-Create Project 2、进入Root Folder Name,这是工程的根目录,后面的自动生成的文件都会对应此根目录产生 3、进入Starting Directory,这个源代码目录与工程的根目录相连 4、进入Output File Path,这里可以选择QAC分析后的输出文件,好的情况就是用一个专门的目录和工程根目录相连 5、Replicate source tree structure in output paths通常是为输出部分建立一个子目录结构,这里可以有2种选择,可以选择Parallel to Source Structure为源代码建立一个平行的目录结构,或者选择Sub-path to each source location把规定的输出的子目录嵌入到源工程目录下面 6、选择File Extensions可以加入项目,通常只要选择一个.C文件,包括对.H文件也就被加入 7、为文件夹选择一个个性,可能会使用默认设置为起始点,可以在QAC中选择Configuration菜单 8、点击OK就是建立了工程,包含源文件工程和子文件夹 9、保存文件,外部扩展名为.prj 注意:也可以在已有的项目上自动生成一个文件夹,点击菜单Edit > Auto-create Sub-Folders,其余步骤和以上相同 文件夹参数:包括文件夹名称、默认源路径、输出路径和三种个性 可以进入Edit > Folder Parameters只可以改变文件夹参数,进入Edit > Propagate Changes to Sub-Folders可以改变所有子文件夹参数 2.2、手动生成文档及参数说明 生成手动文档步骤: 1、从菜单File中选择New Project,显示一个对话框New Project Parameters 2、进入Root Folder Name,输入一个项目名称 3、进入Default Source Path为项目初始化文件夹,这个路径可以改变所有子文件夹 4、在Output File Path中选择需要输出的分析文档 5、为工程选个个性 6、点击 OK创建项目,这工程的配置是唯一的文件夹 7、按要求增加更多的子文件夹和文件按要求 8、保存文件,外部扩展名为.prj 文件夹参数;在File > Reopen这项中可以有10多个选项,当没用的文件可以选择Clean-up。 文件和目录的位置时重新打开项目,将检查的存在。如果不存在一个条目将显示下面的对话框。有的更正可以自动应用的过程。 2.3、选择输出文件 一般文件夹的层次结构在在左边显示,选择的列表在文件的右边显示 所有的选择都在Browse 和d Reports这两个菜单中 A、如果选择单个文件或一组文件,则使用 B、否则当前所选文件夹,再加上所有子其文件夹,窗体所选内容。这意味着使用这些文件夹中的所有文件。 在浏览器内修改,有可能会改变开始的选择,用Select Files…在File菜单内 2.4、互相比较和环境变化的报告 2.4.1、根路径 2.4.2、基于GUI的环境变量创建 2.4.3、相对路径和环境变量的运用 选择Apply Relative Paths项可以选择相对路径减少的所有文件条目,根目录在右上角,表示保存项目文件的位置,确定路径是否合适相对路径减少。 选择Make file paths in each folder relative to its Default Source Path entry项,如果想要应用一个虚拟的环境变量表达默认每个文件的源路径到其他文件条目下。 在Available Environment Variables列表下,可以添加EVs to Apply至右边框中,将这种替换只发生在项目中的项的文件或关联的路径不受相对路径减少的个性 选择Apply path reduction to personality file entries associated with the project项,为了继续应用相对路径和环境变量在文件路径下的个性定义 选择Remove all path reduction from the project and associated personalities项若要撤消所有的相对路径和环境变量从相关个性设置项目恢复到完全在所有情况下限定的路径 例如,一个被重建的“Diff”项目如下所示与充分的relative道路实施 3、 配置QAC 为应用程序配置主要通过可访问Configuration > Options选项卡,有以下几点: Annotated Source 附加说明源 Cross-Module Analysis 跨模块分析 Custom Reports 自定义报告 Default Personalities 默认特性 Editor Preferences 编辑选项 Environment 环境 (Product)Extensions (产品)条目 Project File Options 项目文件选择 要查看您的安装与那些一起中的个性的一组在您的项目中定义,可以在Configuration下选择Message Personalities, Analyser Personalities or Compiler Personalities这几个选项 当创建了一个额外的特性,也可以设置它们成为系统默认,在Configuration>Options>Default Personalities下设置 3.1、配置编译器特性 看附录A 3.1.1、设置系统头文件 在系统包括系统标题选项卡上的标题,设置您系统标头包含路径 可以点击Suppress Output阻止这些头文件,当阻止了那些头文件,一些从特定的头文件或路径中产生的分析数据也不能在.err、.met文件中出现 您可以手动输入是相对于当前项目的路径位置,虽然建议进行完整路径选择和然后将任何选择的道路减少保存项目的过程中的应用操作 3.1.2、设置系统宏 在System Macro Defines下的Project Macros菜单中,设置宏同编译器或开发环境一致,宏可以在Compiler Personality或Analyser Personality设置 3.1.3、设置实现定义的类型 在c编译器里有3中类型定义,在“implementation defined”中选择,如下: size_t 一种无符号必需类型通过sizeof操作表示返回类型 ptrdiff_t 一种有有符号必需类型用减法运算的两个指针来表示 wchar_t 它反映了类型的范围内的整数类型字符文本和宽字符字符串 在Data Types下的Intrinsic Types条目控制这些类型的方法实施,需要以匹配编译器配置环境。所载入的任何相应类型声明头文件(e.g. stddef.h, stdio.h)必须反映内在匹配值类型。如果不符合,qac提示等级9的警告,如有必要,检查您的头文件确定适当的设置这些选项。 如上所述:QAC随提供一套标准库的头文件,如果想改变这些类型定义,必须先明白QAC内部的定义类型,因为那些头文件包含一些声明ptrdiff_t, size_t 和wchar_t,还有3种宏指令定义PRQA_PTRDIFF_T, PRQA_SIZE_T,和PRQA_WCHAR_T, 3.1.4、编译器扩展 许多编译器制造商实施 ISO C 的扩展语言定义来利用特定的硬件环境。特别是在嵌入式软件代码的速度和空间是重要 使用的语言扩展的危险是他们妥协可移植性。源代码越来越依赖于编译器和硬件环境。 QA C 是能够分析各种不同的语言变体和扩展,但它不是通常能够解释扩展在语义上。通常,必须配置该工具等,非标准关键字将被忽略。 有几种方法可以为此配置QAC,看附录B–extensions部分
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

回眸&啤酒鸭

今天加餐!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值