![]() |
|
MISRA-C:2004 Rule 6.2: (Required) |
|
||||
![]() | |||||||
Example Code:
/* PRQA S 2982,2984,3205 ++ */
#include "misra.h"
#include "m2cmex.h"
static S8 test_0602a(void);
static U8 test_0602b(void);
extern S16 test_0602( void )
{
u8a = 1u; /* Correct usage of unsigned char for numeric data */
s8a = 0; /* Correct usage of signed char for numeric data */
pca = 'u'; /* Correct usage of plain char for character data */
s8a = pca; /* MISRA Violation */
u8a = pca; /* MISRA Violation */
s8a = pca + 1; /* MISRA Violation */
u8a = pca + 1; /* MISRA Violation */
s8a = test_0602a();
u8a = test_0602b();
return 0;
}
static S8 test_0602a(void)
{
return pca; /* MISRA Violation */
}
static U8 test_0602b(void)
{
return pca; /* MISRA Violation */
}
QAC messages that encompass this guideline:
| 4413 | An expression of 'essentially character' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4414 | An expression of 'essentially character' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
Related rules:
| Rule 10.1 | The value of an expression of integer type shall not be implicitly converted to a different underlying type if: a) it is not a conversion to a wider integer type of the same signedness, or b) the expression is complex, or c) the expression is not constant and is a function argument, or d) the expression is not constant and is a return expression |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |