Note 917: Prototype coercion (arg. no. 1) int to short

Post a reply


This question is a means of preventing automated form submissions by spambots.

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is OFF
Smilies are OFF

Topic review
   

Expand view Topic review: Note 917: Prototype coercion (arg. no. 1) int to short

Re: Note 917: Prototype coercion (arg. no. 1) int to short

by evilfranky » Mon Apr 19, 2021 3:41 pm

Hi

Thanks for the clarification, it is indeed a rule from MISRA 1998

Re: Note 917: Prototype coercion (arg. no. 1) int to short

by Michael Metivier » Fri Apr 16, 2021 7:00 pm

If he's using version 8 of PC-Lint, he's probably also using the 1998 version of the MISRA rules, which are numbered sequentially up to 127.

Re: Note 917: Prototype coercion (arg. no. 1) int to short

by evilfranky » Wed Apr 07, 2021 11:56 am

Hi

I'm afraid there is no help to be expected. I mean PC-Lint is correct: It's an implicit conversion from int to signed short

Instead to cast you could either change the function signature to

Code: Select all

extern void my_function_with_parameter( int iParm,  BOOL bParmBool );
or

suppress the message

Code: Select all

my_function_with_parameter( 0, TRUE ); //lint !e917
Kind Regards

PS: You have referenced MISRA rule 77 -> but there is no such rule in MISRA C 2004/2012 ?

Note 917: Prototype coercion (arg. no. 1) int to short

by ChristophMS » Tue Mar 16, 2021 12:59 pm

Hello folks,

this day, I’ve got a problem which I cannot solve by myself. I already tried but I can’t figure it out how to solve that.
The background of the problem is that I’m currently porting software from a 16 bit to a 32 bit system and I’m trying to keep the function interfaces exactly the same.
E.g. I’ve got a C-function prototype

Code: Select all

extern void my_function_with_parameter( INT2 iParm,  BOOL bParmBool );
with the following types defined:

Code: Select all

typedef signed short INT2;
typedef unsigned char BOOL;
Further defined are

Code: Select all

#define FALSE ( (BOOL)0 )
#define TRUE  ( !FALSE  )
If I now try to call this function by

Code: Select all

my_function_with_parameter( 0, TRUE );
I always get

Code: Select all

Note 917: Prototype coercion (arg. no. 1) int to short [MISRA Rule 77]
At the moment, I have to cast the first parameter to INT2 every time I’m calling this function.
I’ve already tried to work with strong types but that did not work.

I'm using a quiet old version of PC lint (v8.00i) but hopefully you can help me with that problem.

Is there somone who can help me?

Regards

ChristophMS

Top