Rule M10.1.1

6.10 Arithmetic Type Conversions

Moderators: misra-c, david ward

Post Reply
phdenis
Posts: 9
Joined: Sun Jun 24, 2018 11:34 pm
Company: Capgemini

Rule M10.1.1

Post by phdenis » Thu Dec 05, 2019 10:13 pm

Hello,

I've a problem when using the memset function, the error M10.1.1 is raised.
Error raised by the MISRA Tool used (RTRT):
line 12 row 30: Rule M10.1.1
Error: Implicit conversion of an integer expression to a different signedness is not allowed

Regarding the memset prototype,
void *memset (void *s, int c, size_t n);

The content of the test.h file is given see below:

Code: Select all

#ifndef __TEST_H__
#define __TEST_H__

#define CST_UZERO   0U
#define CST_STRIPV4 16U /* IP: AAA.BBB.CCC.DDD */

typedef signed char SINT8_T;
typedef SINT8_T STRIPV4_T[CST_STRIPV4];

void MyFunc(void);

#endif /* __TEST_H__ */

The content of the test.c file is given see below:

Code: Select all


#include "test.h"
#include <string.h>

void MyFunc(void)
{
    /* Local Variable(s) */
    STRIPV4_T NtpAddr1;
    
    /* Init */
    (void) memset(&NtpAddr1, CST_UZERO, CST_STRIPV4);
    
    return;
}


phdenis
Posts: 9
Joined: Sun Jun 24, 2018 11:34 pm
Company: Capgemini

Re: Rule M10.1.1

Post by phdenis » Thu Dec 05, 2019 10:14 pm

I've found the problem, the 2nd parameter of memset is a int and not unsigned int.
Then by deleting the U for the constant everything is OK now.

Thanks anyway
Phil

Post Reply

Return to “6.10 Arithmetic Type Conversions”