misra Questions

5

Solved

I thought those terms where synonymous, but a note in MISRA regarding dead code indicates this to be wrong? What's the difference? Is one a subset of the other?
Emmanuelemmeline asked 2/4, 2014 at 5:58

5

I want to execute a terminal command of Linux in a C program. Currently I am using system() function but I want to use any other as the system() function is banned as per MISRA. For example, how ca...
Gudren asked 5/6, 2015 at 9:1

7

Solved

Regarding to MISRA C 2012 rule 15.4 - "There should be no more than one break or goto statement used to terminate any iteration statement." - is this example correct? Can anyone confirm t...
Childbed asked 25/2, 2021 at 13:32

3

Solved

I'm facing MISRA C 2012 violation that I can't understand. Following is the code: #define I2C_CCRH_FS ((uint8_t)0x80) #define I2C_CCRH_DUTY ((uint8_t)0x40) #define I2C_CCRH_CCR ((uint8_t)0x0F) ty...
Technique asked 7/6, 2018 at 8:29

3

Solved

Suppose following code is given. class A { public: virtual void someMethod() { std::cout << "class A" << std::endl; } }; class B : public A { public: ... virtual void someMethod...
Metcalf asked 28/9, 2013 at 10:20

1

Solved

I'm working on a project where we are appling MISRA 2004. On most of the violations I got the reason, but one I don't understand: Its in the if-statement with && and || operations. Example:...
Caustic asked 24/3, 2022 at 9:38

13

Solved

Our organization has a required coding rule (without any explanation) that: if … else if constructs should be terminated with an else clause Example 1: if ( x < 0 ) { x = 0; } /* else n...
Wallachia asked 28/1, 2016 at 5:16

3

Solved

I am working on embedded C. Could somebody help me which piece of code? Is efficient in terms of robustness, memory as well as Misra friendly? Code1: if (func() == 1 || func() == 2) { /* Body of t...
Camper asked 12/1, 2022 at 8:2

3

In my firm project, the AUTOSAR platform defines booleans like this typedef unsigned char boolean; plus #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif This is not mo...
Frigging asked 25/11, 2020 at 18:34

5

Solved

Often I built functions, in C, that checks some parameters and return an error code. Which is the best approach to stop the values checking when I found an error? First example: ErrorCode_e myCh...
Chokecherry asked 3/3, 2017 at 9:38

3

In my current project, which uses the MISRA 2004 standard, we use three GCC compilers, versions 3.2.3, 4.4.2 and 5.4.0. We run build checks with the pedantic switch and c89 standard and a load of o...
Albritton asked 11/8, 2020 at 9:54

4

Solved

Why does MISRA 14.5 say that the continue statement must not be used?
Streamlet asked 11/6, 2012 at 7:4

4

I guess this must have been asked before, but I could not get a specific yes/no answer. I have this code snippet : union integer_to_byte { signed int IntPart; unsigned char BytePart[2]; }; typ...
Munafo asked 24/3, 2020 at 14:31

2

Solved

My assumption is that this is going to mess with checkers and stack analysis. I can't prove my assumption and I don't think C99 will complain. Probably neither c89 will because the definition is i...
Vindictive asked 18/12, 2018 at 9:16

3

Solved

I'm using IAR Workbench compiler with MISRA C:2004 checking on. The fragment is: #define UNS_32 unsigned int UNS_32 arg = 3U; UNS_32 converted_arg = (UNS_32) arg; /* Error line --> */ UNS_32 i...
Maximilianus asked 4/2, 2012 at 1:47

4

Solved

As per the MISRA rule The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type #include <stdbool.h> #includ...
Allometry asked 12/10, 2018 at 13:12

3

Solved

My team is developing a embedded system where we need to follow MISRA C++. We are refactoring the code to use less virtual methods so we are trying to implement the CRTP to use static polymorphism...
Amalamalbena asked 11/10, 2018 at 8:42

3

Solved

I struggle with this question very often and couldn't find any clear solution. I think I know the motivation of getters/setters. Prior Information: When realizing real life data, usually the data...
Sloganeer asked 5/10, 2018 at 8:38

2

Solved

It could be argued that in many cases X-macros increase safety, because it makes easier to make sure that generated arrays are the same length for example. However, Misra C (from 2004 reference)...
William asked 27/9, 2018 at 8:1

1

Solved

I have a project I'm developing in C99 and I'm trying to make it compliant with the MISRA 2012 standard. In one file I define an enum where each value should be treated as a flag: /** * Enumerat...
Rankin asked 16/8, 2018 at 8:2

4

Solved

What can I do to avoid MISRA giving this error for the code below? I tried casting with (unit16_t). But then it didn't allow an explicit conversion. Illegal implicit conversion from underlying MIS...
Aspirin asked 15/6, 2011 at 14:33

2

Are there any open-source or free tools out there, that check the MISRA C compliance?
Inverse asked 18/2, 2011 at 16:33

3

I am facing scenario where rule 9.1 getting violated. I want to read an auto variable(having garbage value while declaring) before initialization and to assign null if it is not null. If it ...
Teshatesla asked 19/12, 2017 at 4:44

4

Solved

I get the following warning from our analysis tool Composite expression assigned to a wider essential type This is the code: uint32_t result; uint8_t resolution; result = 1U << resolution; ...
Practitioner asked 24/10, 2017 at 11:1

2

Solved

I switched to fixed-length integer types in my projects mainly because they help me think about integer sizes more clearly when using them. Including them via #include <inttypes.h> also inclu...
Mccarthy asked 26/11, 2016 at 19:38

© 2022 - 2025 — McMap. All rights reserved.