![]() |
|
MISRA C:2012 Rule-10.3: (Required) |
|
||||
![]() | |||||||
Amplification:
The following operations are covered by this rule:
Exception:
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#ifndef BEXP
#define BEXP bla
#endif
static BL fbl(void);
static PC fpc(void);
static N1 fn1(void);
static int16_t fs16(void);
static uint16_t fu16(void);
static float32_t fft32(void);
extern int16_t rule_1003_from_Boolean( void )
{
bla = fbl();
pca = fpc();
n1a = fn1();
sia = fs16();
uia = fu16();
fta = fft32();
return 0;
}
/*****************************************/
static BL fbl(void)
{
bla = BEXP; /* */
blf(BEXP); /* */
return (BEXP); /* */
}
/*****************************************/
static PC fpc(void)
{
pca = BEXP; /* 4401 */
pcf(BEXP); /* 4401 */
return (BEXP); /* 4401 */
}
/*****************************************/
static N1 fn1(void)
{
n1a = BEXP; /* 4402 */
n1f(BEXP); /* 4402 */
return (BEXP); /* 4402 */
}
/*****************************************/
static int16_t fs16(void)
{
s16a = BEXP; /* 4403 */
s16f(BEXP); /* 4403 */
return (BEXP); /* 4403 */
}
/*****************************************/
static uint16_t fu16(void)
{
u16a = BEXP; /* 4404 */
u16f(BEXP); /* 4404 */
return (BEXP); /* 4404 */
}
/*****************************************/
static float32_t fft32(void)
{
f32a = BEXP; /* 4405 */
ft32f(BEXP); /* 4405 */
return (BEXP); /* 4405 */
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,2850,2889,2900,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#ifndef CEXP
#define CEXP pca
#endif
static BL fbl(void);
static PC fpc(void);
static N1 fn1(void);
static int16_t fs16(void);
static uint16_t fu16(void);
static float32_t fft32(void);
extern int16_t rule_1003_from_character( void )
{
bla = fbl();
pca = fpc();
n1a = fn1();
sia = fs16();
uia = fu16();
fta = fft32();
return 0;
}
/*************************************
Assignment to BOOL
**************************************/
static BL fbl(void)
{
BL lbla = CEXP; /* 4410 */
bla = CEXP; /* 4410 */
blf(CEXP); /* 4410 */
return(CEXP); /* 4410 */
}
/*************************************
Assignment to char
**************************************/
static PC fpc(void)
{
PC lpca = CEXP; /* */
pca = CEXP; /* */
pcf(CEXP); /* */
return(CEXP); /* */
}
/*************************************
Assignment to enum
**************************************/
static N1 fn1(void)
{
n1a = CEXP; /* 4412 */
n1f(CEXP); /* 4412 */
return(CEXP); /* 4412 */
}
/*************************************
Assignment to signed int
**************************************/
static int16_t fs16(void)
{
int16_t lsia = CEXP; /* 4413 */
s16a = CEXP; /* 4413 */
s16f(CEXP); /* 4413 */
return(CEXP); /* 4413 */
}
/*************************************
Assignment to unsigned int
**************************************/
static uint16_t fu16(void)
{
uint16_t luia = CEXP; /* 4414 */
u16a = CEXP; /* 4414 */
u16f(CEXP); /* 4414 */
return(CEXP); /* 4414 */
}
/*************************************
Assignment to float
**************************************/
static float32_t fft32(void)
{
float32_t lfta = CEXP; /* 4415 */
f32a = CEXP; /* 4415 */
ft32f(CEXP); /* 4415 */
return(CEXP); /* 4415 */
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,2889,2983,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#ifndef EEXP
#define EEXP n1a
#endif
static BL fbl(void);
static PC fpc(void);
static N1 fn1(void);
static N2 fn2(void);
static int8_t fs8(void);
static int16_t fs16(void);
static uint8_t fu8(void);
static uint16_t fu16(void);
static float32_t fft32(void);
extern int16_t rule_1003_from_enum( void )
{
bla = fbl();
pca = fpc();
n1a = fn1();
n2a = fn2();
sca = fs8();
sia = fs16();
uca = fu8();
uia = fu16();
fta = fft32();
return 0;
}
static BL fbl(void)
{
BL lbla = EEXP; /* 4420 */
bla = EEXP; /* 4420 */
blf(EEXP); /* 4420 */
return(EEXP); /* 4420 */
}
/*****************************************/
static PC fpc(void)
{
PC pcl = EEXP; /* 4421 */
pca = EEXP; /* 4421 */
pcf(EEXP); /* 4421 */
return(EEXP); /* 4421 */
}
/*****************************************/
static N1 fn1(void)
{
N1 n1x = AMBER; /* */
n1a = AMBER; /* */
n1f(AMBER); /* */
return(AMBER); /* */
}
/*****************************************/
static N2 fn2(void)
{
N2 n2x = AMBER; /* 4422 */
n2a = AMBER; /* 4422 */
n2f(AMBER); /* 4422 */
return(AMBER); /* 4422 */
}
/*****************************************/
static int8_t fs8(void)
{
SC scl = EEXP; /* 4423 */
s8a = EEXP; /* 4423 */
s8f(EEXP); /* 4423 */
return(EEXP); /* 4423 */
}
/*****************************************/
static int16_t fs16(void)
{
s16a = EEXP; /* 4423 */
s16f(EEXP); /* 4423 */
return(EEXP); /* 4423 */
}
/*****************************************/
static uint8_t fu8(void)
{
u8a = EEXP; /* 4424 */
u8f(EEXP); /* 4424 */
return(EEXP); /* 4424 */
}
/*****************************************/
static uint16_t fu16(void)
{
u16a = EEXP; /* 4424 */
u16f(EEXP); /* 4424 */
return(EEXP); /* 4424 */
}
/*****************************************/
static float32_t fft32(void)
{
float32_t ftl = EEXP; /* 4425 */
f32a = EEXP; /* 4425 */
ft32f(EEXP); /* 4425 */
return(EEXP); /* 4425 */
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1257,1317,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#define EXP1 0.0
#define EXP2 23.4F
#define EXP3 fta
#define EXP4 dba
static BL fbl(uint8_t m);
static PC fpc(uint8_t m);
static N1 fn1(uint8_t m);
static int16_t fs16(uint8_t m);
static uint16_t fu16(uint8_t m);
extern int16_t rule_1003_from_floating( void )
{
bla = fbl(u8a);
pca = fpc(u8a);
n1a = fn1(u8a);
sia = fs16(u8a);
uia = fu16(u8a);
return 0;
}
static BL fbl(uint8_t m)
{
if (m == 0u)
{
BL bll = EXP1; /* 1266 */
bla = EXP1; /* 1266 */
blf(EXP1); /* 1266 */
return(EXP1); /* 1266 */
}
else if (m == 1u)
{
BL bll = EXP2; /* 1266 */
bla = EXP2; /* 1266 */
blf(EXP2); /* 1266 */
return(EXP2); /* 1266 */
}
else if (m == 2u)
{
BL bll = EXP3; /* 4450 */
bla = EXP3; /* 4450 */
blf(EXP3); /* 4450 */
return(EXP3); /* 4450 */
}
else
{
BL bll = EXP4; /* 4450 */
bla = EXP4; /* 4450 */
blf(EXP4); /* 4450 */
return(EXP4); /* 4450 */
}
}
static PC fpc(uint8_t m)
{
if (m == 0u)
{
PC pcl = EXP1; /* 1266 */
pca = EXP1; /* 1266 */
pcf(EXP1); /* 1266 */
return(EXP1); /* 1266 */
}
else if (m == 1u)
{
PC pcl = EXP2; /* 1266 */
pca = EXP2; /* 1266 */
pcf(EXP2); /* 1266 */
return(EXP2); /* 1266 */
}
else if (m == 2u)
{
PC pcl = EXP3; /* 4451 */
pca = EXP3; /* 4451 */
pcf(EXP3); /* 4451 */
return(EXP3); /* 4451 */
}
else
{
PC pcl = EXP4; /* 4451 */
pca = EXP4; /* 4451 */
pcf(EXP4); /* 4451 */
return(EXP4); /* 4451 */
}
}
static N1 fn1(uint8_t m)
{
if (m == 0u)
{
n1a = EXP1; /* 1266 */
n1f(EXP1); /* 1266 */
return(EXP1); /* 1266 */
}
else if (m == 1u)
{
n1a = EXP2; /* 1266 */
n1f(EXP2); /* 1266 */
return(EXP2); /* 1266 */
}
else if (m == 2u)
{
n1a = EXP3; /* 4452 */
n1f(EXP3); /* 4452 */
return(EXP3); /* 4452 */
}
else
{
n1a = EXP4; /* 4452 */
n1f(EXP4); /* 4452 */
return(EXP4); /* 4452 */
}
}
static int16_t fs16(uint8_t m)
{
if (m == 0u)
{
s16a = EXP1; /* 1266 */
s16f(EXP1); /* 1266 */
return(EXP1); /* 1266 */
}
else if (m == 1u)
{
s16a = EXP2; /* 1266 */
s16f(EXP2); /* 1266 */
return(EXP2); /* 1266 */
}
else if (m == 2u)
{
s16a = EXP3; /* 4453 */
s16f(EXP3); /* 4453 */
return(EXP3); /* 4453 */
}
else
{
s16a = EXP4; /* 4453 */
s16f(EXP4); /* 4453 */
return(EXP4); /* 4453 */
}
}
static uint16_t fu16(uint8_t m)
{
if (m == 0u)
{
u16a = EXP1; /* 1266 */
u16f(EXP1); /* 1266 */
return(EXP1); /* 1266 */
}
else if (m == 1u)
{
u16a = EXP2; /* 1266 */
u16f(EXP2); /* 1266 */
return(EXP2); /* 1266 */
}
else if (m == 2u)
{
u16a = EXP3; /* 4454 */
u16f(EXP3); /* 4454 */
return(EXP3); /* 4454 */
}
else
{
u16a = EXP4; /* 4454 */
u16f(EXP4); /* 4454 */
return(EXP4); /* 4454 */
}
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1257,1317,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
static BL fbl(uint8_t m);
static PC fpc(uint8_t m);
static N1 fn1(uint8_t m);
static uint16_t fu16(uint8_t m);
static float32_t fft32(uint8_t m);
extern int16_t rule_1003_from_signed( void )
{
bla = fbl(u8a);
pca = fpc(u8a);
n1a = fn1(u8a);
uia = fu16(u8a);
fta = fft32(u8a);
return 0;
}
#define EXPA 23L
#define EXPB (23 + 46)
#define EXPC (-1)
#define EXPD (s8a + s8b)
static BL fbl(uint8_t m)
{
if (m == 0u)
{
BL bll = EXPA; /* 1294 */
bla = EXPA; /* 1294 */
blf(EXPA); /* 1294 */
return(EXPA); /* 1294 */
}
else if (m == 1u)
{
BL bll = EXPB; /* 4430 */
bla = EXPB; /* 4430 */
blf(EXPB); /* 4430 */
return(EXPB); /* 4430 */
}
else if (m == 2u)
{
BL bll = EXPC; /* 4430 */
bla = EXPC; /* 4430 */
blf(EXPC); /* 4430 */
return(EXPC); /* 4430 */
}
else
{
BL bll = EXPD; /* 4430 */
bla = EXPD; /* 4430 */
blf(EXPD); /* 4430 */
return(EXPD); /* 4430 */
}
}
static PC fpc(uint8_t m)
{
if (m == 0u)
{
PC pcl = EXPA; /* 1292 */
pca = EXPA; /* 1292 */
pcf(EXPA); /* 1292 */
return(EXPA); /* 1292 */
}
else if (m == 1u)
{
PC pcl = EXPB; /* 4431 */
pca = EXPB; /* 4431 */
pcf(EXPB); /* 4431 */
return(EXPB); /* 4431 */
}
else if (m == 2u)
{
PC pcl = EXPC; /* 4431 */
pca = EXPC; /* 4431 */
pcf(EXPC); /* 4431 */
return(EXPC); /* 4431 */
}
else
{
PC pcl = EXPD; /* 4431 */
pca = EXPD; /* 4431 */
pcf(EXPD); /* 4431 */
return(EXPD); /* 4431 */
}
}
static N1 fn1(uint8_t m)
{
if (m == 0u)
{
n1a = EXPA; /* 1296 */
n1f(EXPA); /* 1296 */
return(EXPA); /* 1296 */
}
else if (m == 1u)
{
n1a = EXPB; /* 4432 */
n1f(EXPB); /* 4432 */
return(EXPB); /* 4432 */
}
else if (m == 2u)
{
n1a = EXPC; /* 4432 */
n1f(EXPC); /* 4432 */
return(EXPC); /* 4432 */
}
else
{
n1a = EXPD; /* 4432 */
n1f(EXPD); /* 4432 */
return(EXPD); /* 4432 */
}
}
static uint16_t fu16(uint8_t m)
{
if (m == 0u)
{
u16a = EXPA; /* */
u16f(EXPA); /* */
return(EXPA); /* */
}
else if (m == 1u)
{
u16a = EXPB; /* 4436 */
u16f(EXPB); /* 4436 */
return(EXPB); /* 4436 */
}
else if (m == 2u)
{
u16a = EXPC; /* 4436 2890 */
u16f(EXPC); /* 4436 2890 */
return(EXPC); /* 4436 2890 */
}
else
{
u16a = EXPD; /* 4434 */
u16f(EXPD); /* 4434 */
return(EXPD); /* 4434 */
}
}
static float32_t fft32(uint8_t m)
{
if (m == 0u)
{
f32a = EXPA; /* 1298 */
ft32f(EXPA); /* 1298 */
return(EXPA); /* 1298 */
}
else if (m == 1u)
{
f32a = EXPB; /* 4437 */
ft32f(EXPB); /* 4437 */
return(EXPB); /* 4437 */
}
else if (m == 2u)
{
f32a = EXPC; /* 4437 */
ft32f(EXPC); /* 4437 */
return(EXPC); /* 4437 */
}
else
{
f32a = EXPD; /* 4435 */
ft32f(EXPD); /* 4435 */
return(EXPD); /* 4435 */
}
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1257,1317,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#define EXP1 23UL
#define EXP2 (23u+46u)
#define EXP3 (u8a+u8b)
#define EXP4 u32a
static BL fbl(uint8_t m);
static PC fpc(uint8_t m);
static N1 fn1(uint8_t m);
static int16_t fs16(uint8_t m);
static float32_t fft32(uint8_t m);
extern int16_t rule_1003_from_unsigned( void )
{
bla = fbl(u8a);
pca = fpc(u8a);
n1a = fn1(u8a);
sia = fs16(u8a);
fta = fft32(u8a);
return 0;
}
static BL fbl(uint8_t m)
{
if (m == 0u)
{
BL bll = EXP1; /* 1295 */
bla = EXP1; /* 1295 */
blf(EXP1); /* 1295 */
return(EXP1); /* 1295 */
}
else if (m == 1u)
{
BL bll = EXP2; /* 4440 */
bla = EXP2; /* 4440 */
blf(EXP2); /* 4440 */
return(EXP2); /* 4440 */
}
else if (m == 2u)
{
BL bll = EXP3; /* 4440 */
bla = EXP3; /* 4440 */
blf(EXP3); /* 4440 */
return(EXP3); /* 4440 */
}
else
{
BL bll = EXP4; /* 4440 */
bla = EXP4; /* 4440 */
blf(EXP4); /* 4440 */
return(EXP4); /* 4440 */
}
}
static PC fpc(uint8_t m)
{
if (m == 0u)
{
PC pcl = EXP1; /* 1293 */
pca = EXP1; /* 1293 */
pcf(EXP1); /* 1293 */
return(EXP1); /* 1293 */
}
else if (m == 1u)
{
PC pcl = EXP2; /* 4441 */
pca = EXP2; /* 4441 */
pcf(EXP2); /* 4441 */
return(EXP2); /* 4441 */
}
else if (m == 2u)
{
PC pcl = EXP3; /* 4441 */
pca = EXP3; /* 4441 */
pcf(EXP3); /* 4441 */
return(EXP3); /* 4441 */
}
else
{
PC pcl = EXP4; /* 4441 */
pca = EXP4; /* 4441 */
pcf(EXP4); /* 4441 */
return(EXP4); /* 4441 */
}
}
static N1 fn1(uint8_t m)
{
if (m == 0u)
{
n1a = EXP1; /* 1297 */
n1f(EXP1); /* 1297 */
return(EXP1); /* 1297 */
}
else if (m == 1u)
{
n1a = EXP2; /* 4442 */
n1f(EXP2); /* 4442 */
return(EXP2); /* 4442 */
}
else if (m == 2u)
{
n1a = EXP3; /* 4442 */
n1f(EXP3); /* 4442 */
return(EXP3); /* 4442 */
}
else
{
n1a = EXP4; /* 4442 */
n1f(EXP4); /* 4442 */
return(EXP4); /* 4442 */
}
}
static int16_t fs16(uint8_t m)
{
if (m == 0u)
{
s16a = EXP1; /* 1291 */
s16f(EXP1); /* 1291 */
return(EXP1); /* 1291 */
}
else if (m == 1u)
{
s16a = EXP2; /* 4447 */
s16f(EXP2); /* 4447 */
return(EXP2); /* 4447 */
}
else if (m == 2u)
{
s16a = EXP3; /* 4443 */
s16f(EXP3); /* 4443 */
return(EXP3); /* 4443 */
}
else
{
s16a = EXP4; /* 4446 */
s16f(EXP4); /* 4446 */
return(EXP4); /* 4446 */
}
}
static float32_t fft32(uint8_t m)
{
if (m == 0u)
{
f32a = EXP1; /* 1299 */
ft32f(EXP1); /* 1299 */
return(EXP1); /* 1299 */
}
else if (m == 1u)
{
f32a = EXP2; /* 4445 */
ft32f(EXP2); /* 4445 */
return(EXP2); /* 4445 */
}
else if (m == 2u)
{
f32a = EXP3; /* 4445 */
ft32f(EXP3); /* 4445 */
return(EXP3); /* 4445 */
}
else
{
f32a = EXP4; /* 4445 */
ft32f(EXP4); /* 4445 */
return(EXP4); /* 4445 */
}
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1257,1317,2889,3408,3447,4492
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#define EXPA (23.45L + 34.56L)
#define EXPB (23.45 + 34.56)
#define EXPC (23.45F + 34.56F)
#define EXPD (f128a+f128b)
#define EXPE (f64a+f64b)
#define EXPF (f32a+f32b)
static float32_t fft32(uint8_t m);
static float64_t fft64(uint8_t m);
static float128_t fft128(uint8_t m);
extern int16_t rule_1003_narrow_floating( void )
{
f32a = fft32(u8a);
f64a = fft64(u8a);
f128a = fft128(u8a);
return 0;
}
static float32_t fft32(uint8_t m)
{
if (m == 0u)
{
f32a = EXPA; /* 4465 */
ft32f(EXPA); /* 4465 */
return(EXPA); /* 4465 */
}
else if (m == 1u)
{
f32a = EXPB; /* 4465 */
ft32f(EXPB); /* 4465 */
return(EXPB); /* 4465 */
}
else if (m == 2u)
{
f32a = EXPC; /* */
ft32f(EXPC); /* */
return(EXPC); /* */
}
else if (m == 3u)
{
f32a = EXPD; /* 4462 */
ft32f(EXPD); /* 4462 */
return(EXPD); /* 4462 */
}
else if (m == 4u)
{
f32a = EXPE; /* 4462 */
ft32f(EXPE); /* 4462 */
return(EXPE); /* 4462 */
}
else
{
f32a = EXPF; /* */
ft32f(EXPF); /* */
return(EXPF); /* */
}
}
static float64_t fft64(uint8_t m)
{
if (m == 0u)
{
f64a = EXPA; /* 4465 */
ft64f(EXPA); /* 4465 */
return(EXPA); /* 4465 */
}
else if (m == 1u)
{
f64a = EXPB; /* */
ft64f(EXPB); /* */
return(EXPB); /* */
}
else if (m == 2u)
{
f64a = EXPC; /* */
ft64f(EXPC); /* */
return(EXPC); /* */
}
else if (m == 3u)
{
f64a = EXPD; /* 4462 */
ft64f(EXPD); /* 4462 */
return(EXPD); /* 4462 */
}
else if (m == 4u)
{
f64a = EXPE; /* */
ft64f(EXPE); /* */
return(EXPE); /* */
}
else
{
f64a = EXPF; /* */
ft64f(EXPF); /* */
return(EXPF); /* */
}
}
static float128_t fft128(uint8_t m)
{
if (m == 0u)
{
f128a = EXPA; /* */
ft128f(EXPA); /* */
return(EXPA); /* */
}
else if (m == 1u)
{
f128a = EXPB; /* */
ft128f(EXPB); /* */
return(EXPB); /* */
}
else if (m == 2u)
{
f128a = EXPC; /* */
ft128f(EXPC); /* */
return(EXPC); /* */
}
else if (m == 3u)
{
f128a = EXPD; /* */
ft128f(EXPD); /* */
return(EXPD); /* */
}
else if (m == 4u)
{
f128a = EXPE; /* */
ft128f(EXPE); /* */
return(EXPE); /* */
}
else
{
f128a = EXPF; /* */
ft128f(EXPF); /* */
return(EXPF); /* */
}
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1317,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#define EXP0 23L
#define EXP1 0LL
#define EXP2 1L + 23LL
#define EXP3 23LL
#define EXP4 sca
#define EXP5 sia
#define EXP6 sla
#define EXP7 sxa
static int8_t fs8(uint8_t m);
static int16_t fs16(uint8_t m);
static int32_t fs32(uint8_t m);
extern int16_t rule_1003_narrow_signed( void )
{
s8a = fs8(u8a);
s16a = fs16(u8a);
s32a = fs32(u8a);
return 0;
}
static int8_t fs8(uint8_t m)
{
if (m == 0u)
{
s8a = EXP0; /* 1257 */
s8f(EXP0); /* 1257 */
return(EXP0); /* 1257 */
}
else if (m == 1u)
{
s8a = EXP1; /* 1257 */
s8f(EXP1); /* 1257 */
return(EXP1); /* 1257 */
}
else if (m == 2u)
{
s8a = EXP2; /* 4463 */
s8f(EXP2); /* 4463 */
return(EXP2); /* 4463 */
}
else if (m == 3u)
{
s8a = EXP3; /* 1257 */
s8f(EXP3); /* 1257 */
return(EXP3); /* 1257 */
}
else if (m == 4u)
{
s8a = EXP4; /* */
s8f(EXP4); /* */
return(EXP4); /* */
}
else if (m == 5u)
{
s8a = EXP5; /* 4460 */
s8f(EXP5); /* 4460 */
return(EXP5); /* 4460 */
}
else if (m == 6u)
{
s8a = EXP6; /* 4460 */
s8f(EXP6); /* 4460 */
return(EXP6); /* 4460 */
}
else
{
s8a = EXP7; /* 4460 */
s8f(EXP7); /* 4460 */
return(EXP7); /* 4460 */
}
}
static int16_t fs16(uint8_t m)
{
if (m == 0u)
{
s16a = EXP0; /* 1257 */
s16f(EXP0); /* 1257 */
return(EXP0); /* 1257 */
}
else if (m == 1u)
{
s16a = EXP1; /* 1257 */
s16f(EXP1); /* 1257 */
return(EXP1); /* 1257 */
}
else if (m == 2u)
{
s16a = EXP2; /* 4463 */
s16f(EXP2); /* 4463 */
return(EXP2); /* 4463 */
}
else if (m == 3u)
{
s16a = EXP3; /* 1257 */
s16f(EXP3); /* 1257 */
return(EXP3); /* 1257 */
}
else if (m == 4u)
{
s16a = EXP4; /* */
s16f(EXP4); /* */
return(EXP4); /* */
}
else if (m == 5u)
{
s16a = EXP5; /* */
s16f(EXP5); /* */
return(EXP5); /* */
}
else if (m == 6u)
{
s16a = EXP6; /* 4460 */
s16f(EXP6); /* 4460 */
return(EXP6); /* 4460 */
}
else
{
s16a = EXP7; /* 4460 */
s16f(EXP7); /* 4460 */
return(EXP7); /* 4460 */
}
}
static int32_t fs32(uint8_t m)
{
if (m == 0u)
{
s32a = EXP0; /* */
s32f(EXP0); /* */
return(EXP0); /* */
}
else if (m == 1u)
{
s32a = EXP1; /* 1257 */
s32f(EXP1); /* 1257 */
return(EXP1); /* 1257 */
}
else if (m == 2u)
{
s32a = EXP2; /* 4463 */
s32f(EXP2); /* 4463 */
return(EXP2); /* 4463 */
}
else if (m == 3u)
{
s32a = EXP3; /* 1257 */
s32f(EXP3); /* 1257 */
return(EXP3); /* 1257 */
}
else if (m == 4u)
{
s32a = EXP4; /* */
s32f(EXP4); /* */
return(EXP4); /* */
}
else if (m == 5u)
{
s32a = EXP5; /* */
s32f(EXP5); /* */
return(EXP5); /* */
}
else if (m == 6u)
{
s32a = EXP6; /* */
s32f(EXP6); /* */
return(EXP6); /* */
}
else
{
s32a = EXP7; /* 4460 */
s32f(EXP7); /* 4460 */
return(EXP7); /* 4460 */
}
}
Example Code:
#pragma PRQA_MESSAGES_OFF 635,1031,1056,1317,2889,3408,3447
#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"
#define EXP0 300U
#define EXP1 1UL
#define EXP2 1ULL
#define EXP3 1UL+23UL
#define EXP4 1ULL+23ULL
#define EXP5 u8a
#define EXP6 u16a
#define EXP7 u32a
static uint8_t fu8(uint8_t m);
static uint16_t fu16(uint8_t m);
static uint32_t fu32(uint8_t m);
extern int16_t rule_1003_narrow_unsigned( void )
{
u8a = fu8(u8a);
u16a = fu16(u8a);
u32a = fu32(u8a);
return 0;
}
static uint8_t fu8(uint8_t m)
{
if (m == 0u)
{
u8a = EXP0; /* 2900 */
u8f(EXP0); /* 2900 */
return(EXP0); /* 2900 */
}
else if (m == 1u)
{
u8a = EXP1; /* 1257 */
u8f(EXP1); /* 1257 */
return(EXP1); /* 1257 */
}
else if (m == 2u)
{
u8a = EXP2; /* 1257 */
u8f(EXP2); /* 1257 */
return(EXP2); /* 1257 */
}
else if (m == 3u)
{
u8a = EXP3; /* 4464 */
u8f(EXP3); /* 4464 */
return(EXP3); /* 4464 */
}
else if (m == 4u)
{
u8a = EXP4; /* 4464 */
u8f(EXP4); /* 4464 */
return(EXP4); /* 4464 */
}
else if (m == 5u)
{
u8a = EXP5; /* */
u8f(EXP5); /* */
return(EXP5); /* */
}
else if (m == 6u)
{
u8a = EXP6; /* 4461 */
u8f(EXP6); /* 4461 */
return(EXP6); /* 4461 */
}
else
{
u8a = EXP7; /* 4461 */
u8f(EXP7); /* 4461 */
return(EXP7); /* 4461 */
}
}
static uint16_t fu16(uint8_t m)
{
if (m == 0u)
{
u16a = EXP0; /* */
u16f(EXP0); /* */
return(EXP0); /* */
}
else if (m == 1u)
{
u16a = EXP1; /* 1257 */
u16f(EXP1); /* 1257 */
return(EXP1); /* 1257 */
}
else if (m == 2u)
{
u16a = EXP2; /* 1257 */
u16f(EXP2); /* 1257 */
return(EXP2); /* 1257 */
}
else if (m == 3u)
{
u16a = EXP3; /* 4464 */
u16f(EXP3); /* 4464 */
return(EXP3); /* 4464 */
}
else if (m == 4u)
{
u16a = EXP4; /* 4464 */
u16f(EXP4); /* 4464 */
return(EXP4); /* 4464 */
}
else if (m == 5u)
{
u16a = EXP5; /* */
u16f(EXP5); /* */
return(EXP5); /* */
}
else if (m == 6u)
{
u16a = EXP6; /* */
u16f(EXP6); /* */
return(EXP6); /* */
}
else
{
u16a = EXP7; /* 4461 */
u16f(EXP7); /* 4461 */
return(EXP7); /* 4461 */
}
}
static uint32_t fu32(uint8_t m)
{
if (m == 0u)
{
u32a = EXP0; /* */
u32f(EXP0); /* */
return(EXP0); /* */
}
else if (m == 1u)
{
u32a = EXP1; /* */
u32f(EXP1); /* */
return(EXP1); /* */
}
else if (m == 2u)
{
u32a = EXP2; /* 1257 */
u32f(EXP2); /* 1257 */
return(EXP2); /* 1257 */
}
else if (m == 3u)
{
u32a = EXP3; /* */
u32f(EXP3); /* */
return(EXP3); /* */
}
else if (m == 4u)
{
u32a = EXP4; /* 4464 */
u32f(EXP4); /* 4464 */
return(EXP4); /* 4464 */
}
else if (m == 5u)
{
u32a = EXP5; /* */
u32f(EXP5); /* */
return(EXP5); /* */
}
else if (m == 6u)
{
u32a = EXP6; /* */
u32f(EXP6); /* */
return(EXP6); /* */
}
else
{
u32a = EXP7; /* */
u32f(EXP7); /* */
return(EXP7); /* */
}
}
Example Code:
#include "misra.h"
#include "m3cmex.h"
static void swa(uint16_t usw, int16_t ssw);
static void swb(uint16_t usw, int16_t ssw);
extern int16_t rule_1003_switch( void )
{
swa(uia, sia);
swb(uia, sia);
return 0;
}
enum {TWENTY = 20};
static void swa(uint16_t usw, int16_t ssw)
{
switch (usw)
{
case 0U:
break;
case 1: /* 0570 */
break;
case 'a': /* 0570 */
break;
case GREEN: /* 0570 */
break;
case TWENTY: /* 0570 */
break;
default:
break;
}
switch (ssw)
{
case 0:
break;
case 1U: /* 0570 */
break;
case 'a': /* 0570 */
break;
case GREEN: /* 0570 */
break;
case TWENTY: /* */
break;
default:
break;
}
}
static void swb(uint16_t usw, int16_t ssw)
{
switch (usw)
{
case 10UL: /* 0572 */
break;
case 20UL: /* 0572 */
break;
default:
break;
}
switch (ssw)
{
case 10L: /* 0572 */
break;
case 20L: /* 0572 */
break;
default:
break;
}
}
QAC messages that encompass this guideline:
| 0570 | This switch case label of 'essential type' '%1s', is not consistent with a controlling expression of essential type '%2s'. |
| 0572 | This switch case label of 'essential type' '%1s' is not consistent with a controlling expression which has an essential type of lower rank (%2s). |
| 1257 | An integer constant suffixed with L or LL is being converted to a type of lower rank on assignment. |
| 1264 | A suffixed floating constant is being converted to a different floating type on assignment. |
| 1265 | An unsuffixed floating constant is being converted to a different floating type on assignment. |
| 1266 | A floating constant is being converted to integral type on assignment. |
| 1291 | An integer constant of 'essentially unsigned' type is being converted to signed type on assignment. |
| 1292 | An integer constant of 'essentially signed' type is being converted to type char on assignment. |
| 1293 | An integer constant of 'essentially unsigned' type is being converted to type char on assignment. |
| 1294 | An integer constant of 'essentially signed' type is being converted to type _Bool on assignment. |
| 1295 | An integer constant of 'essentially unsigned' type is being converted to type _Bool on assignment. |
| 1296 | An integer constant of 'essentially signed' type is being converted to enum type on assignment. |
| 1297 | An integer constant of 'essentially unsigned' type is being converted to enum type on assignment. |
| 1298 | An integer constant of 'essentially signed' type is being converted to floating type on assignment. |
| 1299 | An integer constant of 'essentially unsigned' type is being converted to floating type on assignment. |
| 2850 | Constant: Implicit conversion to a signed integer type of insufficient size. |
| 2851 | Definite: Implicit conversion to a signed integer type of insufficient size. |
| 2852 | Apparent: Implicit conversion to a signed integer type of insufficient size. |
| 2900 | Constant: Positive integer value truncated by implicit conversion to a smaller unsigned type. |
| 2901 | Definite: Positive integer value truncated by implicit conversion to a smaller unsigned type. |
| 2902 | Apparent: Positive integer value truncated by implicit conversion to a smaller unsigned type. |
| 4401 | An expression of 'essentially Boolean' type (%1s) is being converted to character type, '%2s' on assignment. |
| 4402 | An expression of 'essentially Boolean' type (%1s) is being converted to enum type, '%2s' on assignment. |
| 4403 | An expression of 'essentially Boolean' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4404 | An expression of 'essentially Boolean' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
| 4405 | An expression of 'essentially Boolean' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4410 | An expression of 'essentially character' type (%1s) is being converted to Boolean type, '%2s' on assignment. |
| 4412 | An expression of 'essentially character' type (%1s) is being converted to enum type, '%2s' on assignment. |
| 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. |
| 4415 | An expression of 'essentially character' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4420 | An expression of 'essentially enum' type (%1s) is being converted to Boolean type, '%2s' on assignment. |
| 4421 | An expression of 'essentially enum' type (%1s) is being converted to character type, '%2s' on assignment. |
| 4422 | An expression of 'essentially enum' type (%1s) is being converted to a different enum type, '%2s' on assignment. |
| 4423 | An expression of 'essentially enum' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4424 | An expression of 'essentially enum' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
| 4425 | An expression of 'essentially enum' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4430 | An expression of 'essentially signed' type (%1s) is being converted to Boolean type, '%2s' on assignment. |
| 4431 | An expression of 'essentially signed' type (%1s) is being converted to character type, '%2s' on assignment. |
| 4432 | An expression of 'essentially signed' type (%1s) is being converted to enum type, '%2s' on assignment. |
| 4434 | A non-constant expression of 'essentially signed' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
| 4435 | A non-constant expression of 'essentially signed' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4436 | A constant expression of 'essentially signed' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
| 4437 | A constant expression of 'essentially signed' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4440 | An expression of 'essentially unsigned' type (%1s) is being converted to Boolean type, '%2s' on assignment. |
| 4441 | An expression of 'essentially unsigned' type (%1s) is being converted to character type, '%2s' on assignment. |
| 4442 | An expression of 'essentially unsigned' type (%1s) is being converted to enum type, '%2s' on assignment. |
| 4443 | A non-constant expression of 'essentially unsigned' type (%1s) is being converted to a wider signed type, '%2s' on assignment. |
| 4445 | An expression of 'essentially unsigned' type (%1s) is being converted to floating type, '%2s' on assignment. |
| 4446 | A non-constant expression of 'essentially unsigned' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4447 | A constant expression of 'essentially unsigned' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4450 | An expression of 'essentially floating' type (%1s) is being converted to Boolean type, '%2s' on assignment. |
| 4451 | An expression of 'essentially floating' type (%1s) is being converted to character type, '%2s' on assignment. |
| 4452 | An expression of 'essentially floating' type (%1s) is being converted to enum type, '%2s' on assignment. |
| 4453 | An expression of 'essentially floating' type (%1s) is being converted to signed type, '%2s' on assignment. |
| 4454 | An expression of 'essentially floating' type (%1s) is being converted to unsigned type, '%2s' on assignment. |
| 4460 | A non-constant expression of 'essentially signed' type (%1s) is being converted to narrower signed type, '%2s' on assignment. |
| 4461 | A non-constant expression of 'essentially unsigned' type (%1s) is being converted to narrower unsigned type, '%2s' on assignment. |
| 4462 | A non-constant expression of 'essentially floating' type (%1s) is being converted to narrower floating type, '%2s' on assignment. |
| 4463 | A constant expression of 'essentially signed' type (%1s) is being converted to narrower signed type, '%2s' on assignment. |
| 4464 | A constant expression of 'essentially unsigned' type (%1s) is being converted to narrower unsigned type, '%2s' on assignment. |
| 4465 | A constant expression of 'essentially floating' type (%1s) is being converted to narrower floating type, '%2s' on assignment. |
|
||
(c) The Motor Industry Research Association, 2012
|
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |