Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





  MISRA C:2012 Rule 20.5 applicable for inactive code ?
Posted by: Girish - 06-01-2020, 01:43 PM - Forum: 8.20 Preprocessing directives - Replies (1)

Hello,

MISRA C:2012 Rule 20.5 - #undef should not be used.

For the following code snippet, #undef is seen at line 5 and 8.
As Rule 20.5 complains for use of #undef, please let us know whether code at line 8, which is inactive code due to #else is Non-compliant or not according MISRA C:2012 Rule 20.5 ?


1. #define FLAG 100
2.
3. #ifdef FLAG
4. #define L 0
5. #undef L
6. #else
7. #define X 0
8. #undef X
9. #endif

Regards
Girish.M

Print this item

  Rule M10.1.1
Posted by: phdenis - 05-12-2019, 10:13 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

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:
#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:
#include "test.h"
#include

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

Print this item

  MISRA 25th Anniversary
Posted by: david ward - 28-11-2019, 12:25 PM - Forum: Announcements - No Replies

The MISRA consortium, a world-leading collaboration between manufacturers, component suppliers and engineering consultancies, is celebrating 25 years since the landmark publication of Development Guidelines for Vehicle Based Software.

The guidelines, and the revisions and amendments that have followed, and the broader portfolio of MISRA documents published since then have underpinned significant improvements in vehicular software safety; and the success has seen the principles adopted by many other industries.

The MISRA consortium was conceived in the early 1990s as a project in the UK government’s “SafeIT” programme to develop guidelines for embedded software in road vehicle electronic systems. Membership now consists of members from other industries in the safety-related embedded systems world, alongside automotive companies.

The consortium started with eight core members in the funded project, and now consists of a board of ten in voluntary roles.

Landmark publications include the first edition of MISRA C in 1998, MISRA C:2004, guidelines for safety analysis in 2007, MISRA C++ :2008, MISRA C:2012 and guidelines for safety arguments in 2019.

In the late 1980s, the automotive industry had to adapt to more complex systems of embedded electronics in road vehicles. Starting with the publication of our first guidelines in 1994, MISRA has been at the forefront of making sure our safety standards have developed hand-in-hand with the technological breakthroughs in the industry.

Outside of the automotive sector, the MISRA guidelines have supported the development of renowned technological projects. The Joint Strike Fighter (JSF) project C++ Coding Standard and NASA Jet Propulsion Laboratory C Coding Standards, as used on the Mars Rover missions, are both based on MISRA guidelines.

A full press release is available at the main MISRA website at https://www.misra.org.uk/News/tabid/59/Default.aspx along with an infographic at https://www.misra.org.uk/MISRAHome/MISRA...fault.aspx

Print this item

  Executing process
Posted by: phdenis - 17-11-2019, 10:40 PM - Forum: 6.20 Standard Libraries - Replies (2)

Hello,

Regarding the rule 20.11, the call of 'system' shall not be used. But In my current program, I'm creating process by using fork() and system() to start it.

What is the best solution to create process and start it in order to comply with MISRA C 2004 ?

By advance thanks for your answer.

Print this item

  Rule 6-6-3 in while-loops
Posted by: jungsun.goh - 29-10-2019, 07:00 AM - Forum: 6.6 Statements (C++) - Replies (1)

Dear MISRA members,

Regarding the rule 6-6-3:
Does this rule only apply to for-loops or does it also apply to while-loops?

For references, the static analysis tool, Coverity reports a 6-6-3 rule violation when 'continue' statement is used in a while-loop.

Best Regards,
Goh

Print this item

  Rule 10.3 - Bitfield narrower essential type
Posted by: apereira - 24-10-2019, 06:01 AM - Forum: 8.10 The essential type model - Replies (1)

Hello,

Assuming that I have the following structure and enum:

Code:
typedef struct s{
  unsigned int a:5;
  unsigned int b:1;
  unsigned int c:1;
} s;

typedef enum e{
  ZERO = 0,
  ONE = 1,
  TWO = 2,
  THREE = 3
} e;

Why does the following code trigger rule 10.3?

Code:
s fcn(void)
{
  s test;

  test.a = (unsigned int) THREE;

  return test;
}

Print this item

  About Appendix H of MISRA C: 2012
Posted by: Takuya Nishimura - 15-10-2019, 12:18 AM - Forum: 8.1 A standard C environment - Replies (4)

Hello all,

I have some questions about Appendix H of MISRA C: 2012.

Appendix H states that C90 id and C99 id are based on C90 and C99 standard. Therefore, I thought there was only one C90 and C99 standard, but the reference lists multiple C90 and C99 standards. Which standard is used to create the table in Appendix H?

Also, C90 and C99 Standard are not assigned numbers such as C90 id and C99 id. How were the C90 id and C99 id numbering decided?

Print this item

  Rule 10.1: Essentially Boolean operands with & or | bitwise operators
Posted by: suruena - 08-10-2019, 11:16 AM - Forum: 8.10 The essential type model - Replies (3)

Hello,

In the MISRA-C:2012 essential type model, Rule 10.1 ("Operands shall not be of an innappropriate 'essential type'") allows to use essentially Boolean operands with the && and || logical operators, but disallows to use them with the & or | bitwise operators. However, as the && and || logical operators have short-circuit behavior (i.e. lazy evaluation, resulting effectively in an 'if ... else ...' expression), in some situations it may be preferred to use operators with eager evaluation (i.e. both operands are always evaluated, regardless of the value of the first parameter). For example, to avoid jump instructions in the generated code (the timing differences can be a problem for hard real-time systems, or even a side-channel timing attack), or just to make clear to the reviewer that the order of evaluation is not important.

As an essential Boolean can only hold the value 0 or 1, in my opinion it would be safe to allow the use of the & and | bitwise operators with essentially Boolean operands, in addition to the && and || logical operators. It's true that the order of evaluation won't be ensured when using bitwise operators (marked as unspecified behaviour by the standard), however this shouldn't be a problem when using them with just Boolean variables (i.e. instead of function calls returning a Boolean value) or expressions (or even Boolean literals); and futhermore Rule 13.2 already forbids side effects in expressions with multiple evaluation orders. Was the usage of the & and | bitwise operators disallowed with essentially Boolean operands due to problematic situations with the language (like the evaluation order), or either because it is not a typical C idiom? Do you think the usage of these & and | bitwise operators with Boolean operands can be considered safe (at least in some situations)?

Thanks in advance for any answer.

Print this item

  Guidelines for Automotive Safety Arguments published
Posted by: david ward - 27-09-2019, 01:22 PM - Forum: Announcements - No Replies

The MISRA Guidelines for Automotive Safety Arguments are now available to purchase from the MISRA webstore.

The guidelines provide clarity on how to develop Safety Arguments in line with existing standards such as ISO 26262, with a view to justifying that the risk associated with an automotive system is within industry norms. Types of evidence to support the argument are also suggested, as well as advice on practical application.

One of the specific motivations for developing these guidelines was to support the requirements for a safety case in ISO 26262. Since ISO 26262:2018 the safety case is now explicitly required to be based on an argument.

Print this item

  Guidelines for Automotive Safety Arguments published
Posted by: david ward - 27-09-2019, 01:20 PM - Forum: MISRA Safety Arguments discussions - No Replies

The MISRA Guidelines for Automotive Safety Arguments are now available to purchase from the MISRA webstore.

The guidelines provide clarity on how to develop Safety Arguments in line with existing standards such as ISO 26262, with a view to justifying that the risk associated with an automotive system is within industry norms. Types of evidence to support the argument are also suggested, as well as advice on practical application.

One of the specific motivations for developing these guidelines was to support the requirements for a safety case in ISO 26262. Since ISO 26262:2018 the safety case is now explicitly required to be based on an argument.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,206
» Latest member: nileseo4605
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 193 online users.
» 0 Member(s) | 190 Guest(s)
Bing, Google, UptimeRobot

Latest Threads
Rule 7.0.5, example non-c...
Forum: 4.7 Standard conversions
Last Post: cgpzs
17-04-2025, 12:10 PM
» Replies: 0
» Views: 158
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 285
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 271
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 180
Rule 8.2.8 - why aren't a...
Forum: 4.8 Expressions
Last Post: misra cpp
28-03-2025, 01:05 PM
» Replies: 1
» Views: 198
Typo in Appendix C of MIS...
Forum: 8.10 The essential type model
Last Post: Yordan Naydenov
17-03-2025, 02:58 PM
» Replies: 0
» Views: 158
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 239
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 201
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 258
A8-4-5: Should have an ex...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
21-02-2025, 12:58 PM
» Replies: 3
» Views: 672