![]() |
![]() |
2893 | ![]() |
||||
![]() | |||||||
| Conversion to unsigned | |||||||
Dataflow analysis has identified a code construct which is suspicious. The code may be entirely safe but further investigation is advisable. The value of an object or a non-constant expression is being converted to an unsigned type and examination of the immediate context suggests that the value could sometimes be negative. This will happen in the example below unless the parameter 'n' is greater than 0.
/*PRQA S 291,2017,2983,2986,3120,3199,3203,3227,3408 ++*/
void foo(int n)
{
unsigned char ucx;
int sia = -10;
int i;
for (i = 0; i < n; ++i)
{
sia = sia + 20;
}
ucx = sia; /* 2893 3757 */
}
No MISRA C:2012 Rules applicable to message 2893
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |