This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
Hi every body,
i am trying to get familiar with MISRA rules recently,
i used the function:
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
and have these:
#1393-D (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a wider integer type of the same signedness
#1406-D (MISRA-C:2004 12.7/R) Bitwise operators shall not be applied to operands whose underlying type is signed
and when i try to enable any peripheral :
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0) ; while(!SysCtlPeripheralReady(SYSCTL_PERIPH_CAN0)){}
i have this warnings:
#1464-D (MISRA-C:2004 10.6/R) A "U" suffix shall be applied to all constants of unsigned type
any one can help?
thanks
Sarea
I can explain some things. I cannot tell you the best way to fix it.
This compiler team does not supply any driver libraries. So I cannot tell you, for certain, the cause of your problem. But I can reproduce the same diagnostics with this source code ...
/* file.c */ typedef unsigned int uint32_t; void call(uint32_t arg); void fxn(void); void fxn(void) { call(10 | 20); /* two MISRA diagnostics */ call(10u | 20u); /* no diagnostics */ }
Here is a simple compile command and the resulting diagnostics ...
C:\path\to\dir>armcl -ps --check_misra --verbose_diagnostics file.c "file.c", line 10: warning: (MISRA-C:2004 12.7/R) Bitwise operators shall not be applied to operands whose underlying type is signed call(10 | 20); /* two MISRA diagnostics */ ^ "file.c", line 10: warning: (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if the expression is not constant and is a function argument call(10 | 20); /* two MISRA diagnostics */
Note when the "u" constant suffix is used, there are no diagnostics. The suffix says the type of the constant is unsigned int.
It is likely that this driver library is not documented or tested to be MISRA compliant.
Thanks and regards,
-George