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

Username
  

Password
  





  Recommendations to resolve issue 12.4
Posted by: jbrookley - 25-02-2015, 10:16 PM - Forum: 6.12 Expressions - Replies (1)

Hello,

I had a question regarding rule 12.4 and realize I asked a similar question here:

http://www.misra-c.com/forum/viewtopic.php?f=68&t=1296

I didn't want to bump an old thread so I started a new one (hopefully, that's ok).

I received an error for rule 12-4 with the following section of code:

Code:
if((CommandState!=7u)&&(CommandState!=8u)&&(CommandState!=9u)&&(CommandState!=10u)&&(CommandState!=11u)&&(commData==0x24u)) /* Please ignore the fact this is written inefficiently for now */
{
        CommandState = 0u;
}

I resolved this issue using the following section of code but I wasn't sure if this is the best way to handle the code or if it's recommended to handle it using a different technique:

[code]if(commData==0x24u)
{
if(CommandState>=7u)
{
if(CommandState

Print this item

  MISRA C:2012 on Auto Code
Posted by: sundarn - 21-02-2015, 06:34 AM - Forum: MISRA C:2004 to MISRA C:2012 migration - Replies (1)

MISRA C:2004 had an additional document MISRA AC AGC explaining the application of MISRA-C 2004 in the context of automatic code generation and it do gives applicability of the rule on Model level with MOD category. In MISRA C:2012 a small section is added to explain the applicability on auto code in Appendix E where i could not find any details on the action required at model level. If i am moving from MISRA C:2004 to MISRA C:20012 what rules should i take to address at model level. Will MISRA be releasing any document in this regard.

Print this item

  Rule 8.9
Posted by: anuj1085 - 18-02-2015, 12:46 PM - Forum: 8.8 Declarations and defnitions - Replies (1)

Below is my query:

# file1 a.c includes a # file 2 a.h
================================

#file2 a.h contains following code snippet
-------------------------------------------------------------
extern int eix;
static int siz;

eix and siz are not referenced from anywhere i.e. they are unused. So should the violation for this rule should be reported on these variables as well or the violation shoudl only be reported if the variable is used somewhere in the code.

Print this item

  What is the essential type of -123L?
Posted by: misra-c - 17-02-2015, 01:26 PM - Forum: 8.10 The essential type model - Replies (1)

When applying the essential type model, what is the essential type of "-123L"?

Print this item

  Rule 20.3 space after #include
Posted by: misra-c - 13-02-2015, 12:36 PM - Forum: 8.20 Preprocessing directives - Replies (1)

The amplification to rule 20.3 states that the rule applies "after macro replacement" has been performed. Is the number/absence of spaces and comments between #include and the " or < irrelevant?

So for example:

Code:
#include              /* no space - compliant ? */
#include/* comment*/  /* compliant  ? */.

Print this item

  Rule 14.2 What is meant by assign"
Posted by: misra-c - 13-02-2015, 12:15 PM - Forum: 8.14 Control statement expressions - Replies (1)

In the 1st clause what is meant by “assign a value to the loop counter”. May this “value” be an expression with side-effects?

Code:
int index;
for ( set_val(&index) ;  index < 10 ; index++) // Is this compliant if set_val assigns to index
Note: the 2nd and 3rd clauses explicitly refer to expressions and whether side-effects are permitted.

Print this item

  8.10.3 Are increment operator composite?
Posted by: misra-c - 13-02-2015, 10:13 AM - Forum: 8.10 The essential type model - Replies (1)

Are post-fix and pre-fix increment and decrement operators treated as composite operators?

Print this item

  Rule 10.2 Are increment/decrement compliant
Posted by: misra-c - 13-02-2015, 10:01 AM - Forum: 8.10 The essential type model - Replies (1)

Are the increment and decrement operators on essentially character type allowed?

Code:
char c = ‘A’;
   c++;  /* compliant or not compliant */

Print this item

  Rule 8.8 Does this apply to after pre-processing
Posted by: misra-c - 13-02-2015, 09:56 AM - Forum: 8.8 Declarations and defnitions - Replies (1)

Is the following code compliant with rule 8.9 “An object should not be defined at block scope if its identifier only appears in a single function”?

Code:
#define MACHINE1 0
int32_t x;   /* compliant or not? */

void fn1 ( void )
{
   x = 3;
}

int32_t fn2 ( void )
{
#if ( MACHINE1 )
   return x;
#else
   return 0;
#endif
}

Print this item

  Dir 4.8 2 struct pointers in a Translation unit
Posted by: misra-c - 13-02-2015, 09:46 AM - Forum: 7.4 Code design - Replies (1)

What happens if there are 2 pointers to a struct/union in a translation unit. One which accesses the details of the struct/union and the other does not. For Example:
File1.h

Code:
struct X { int32_t i1 };
  typedef struct X * ptrX;
  extern  void use_ptrX ( ptrX p );

File1.c
Code:
void fn ( ptrX a, ptrX b )
  {     /* no reference to a->i1 in translation unit  - does the type of "a" need to be opaque? */
     use_ptrX ( a );
     use_int32 ( b -> i1 ) ;
}

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,309
» Latest member: 1fuhd
» Forum threads: 1,066
» Forum posts: 2,933

Full Statistics

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

Latest Threads
13.2 Was TC2 correctly ap...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:47 PM
» Replies: 1
» Views: 625
20.12 Does the stringific...
Forum: 8.20 Preprocessing directives
Last Post: misra-c
08-10-2026, 12:40 PM
» Replies: 1
» Views: 554
13.3 Should side effects ...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:37 PM
» Replies: 1
» Views: 428
11.6 pointer to pointer t...
Forum: 8.11 Pointer type conversions
Last Post: misra-c
08-10-2026, 12:21 PM
» Replies: 2
» Views: 1,032
What is the UTLR of -1?
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 12:15 PM
» Replies: 1
» Views: 598
10.3 Clarify if narrower ...
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 11:57 AM
» Replies: 1
» Views: 508
It 8.12 intended to be so...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
08-10-2026, 11:50 AM
» Replies: 1
» Views: 455
Rule 0.1.1 Example f4
Forum: 4.0 Language independent issues
Last Post: cgpzs
07-10-2026, 11:07 AM
» Replies: 3
» Views: 728
Rule 6-2-2 Usage of std::...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
25-09-2026, 05:43 PM
» Replies: 1
» Views: 437
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 541