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

Username
  

Password
  





  How to fix Warnings 10.1 and 10.3
Posted by: chas - 12-06-2015, 06:58 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

Hi. We're new to MISRA-2004. Can anyone explain why I get these warnings and how to fix them. We are using Code Composer.

unsigned int x = 0U;
unsigned int* px;

px = &x; /* 10.1 warning */
px = (unsigned int*)&x; /* 10.3 warning */

Print this item

  8.10.3 Is ~ operator composite?
Posted by: miyanom - 04-06-2015, 02:27 AM - Forum: 8.10 The essential type model - Replies (1)

In 8.10.3, ~ operator is not defined as a composite operator.
Is it necessary to treat ~ operator as composite?

If ~ operator is not composite, then is the following code compliant with Rule 10.6?
u16a = ~u8a;

Print this item

  Rule 11.1, 11.2 (and others?) vs conversion caused by equality operators (and similar)?
Posted by: pkruk - 03-06-2015, 02:14 PM - Forum: 8.11 Pointer type conversions - Replies (1)

Hello,

rules 11.1 and 11.2 disallow conversions between pointer to a function or incomplete type, and any other type:

Code:
void (*fp1)(short);
void (*fp2)(int);

fp2 = fp1;          /* Not-compliant - different function */
fp2 = 0x8000;       /* Not-compliant - integer */

What if the conversion happens for example in equality operator:
Code:
fp2 == fp1;         /* Compliant or Not-compliant ? */
fp2 != 0x8000;      /* Compliant or Not-compliant ? */

Following example from Rule 11.1 suggests it's also non-compliant:
Code:
if ( fp2 != NULL )  /* Compliant - exception 1 (NULL) */

Print this item

  Loops violate Rule 14.3
Posted by: chrisT - 02-06-2015, 10:20 AM - Forum: 6.14 Control Flow - Replies (2)

Hello.

In our company, we have developers who uses

Code:
for(;;)
loops. Are these a violation against rule 14.3?

kind regards.

Print this item

  RSS support gone
Posted by: cweimer - 22-05-2015, 04:03 PM - Forum: General Questions - Replies (1)

Seems your upgrade of phpBB has erased rss support (Smartfeed), was this intended?
Thanks

Print this item

  Example at 11.1 and 11.2
Posted by: ogawa.kiyoshi - 29-04-2015, 09:24 AM - Forum: 8.11 Pointer type conversions - Replies (1)

In example codes in Rule 11.1 and Rule 11.2

#include /* to obtain macro NULL */

in example codes in 11.9

#include

A freestanding environment needs stdarg.h not sodlib.h.
So I prefer to obtain macro NULL,
#include // to obtain macro NULL

Is it reasonable?

ps. in 11.9
/* Could also be stdio.h, stdlib.h and others */

I prefer
/* A free standing environment needs stddef.h */
/* Could also be stdio.h, stdlib.h and others in host environments */

Best Regards.

Print this item

  Rule 2.4 and forward declarations
Posted by: michael.metivier - 21-04-2015, 10:08 PM - Forum: 8.2 Unused code - Replies (2)

Would the use of tags for forward declarations be considered a failure of this rule, if used such as

Code:
struct test;
typedef struct test test_T;

typedef bool (*Callback_T)(test_T const * p_test);

struct test
{
    uint32_t var;
    Callback_T callback;
};
For consistency in type usage, I would prefer to utilize the typedef whenever referring to this structure, including in the callback definition, but this leads our analysis tools to flag that "test" is only used in the typedef.

Print this item

  Clarification for Rule 6.1
Posted by: anuj1085 - 06-04-2015, 09:02 AM - Forum: 6.6 Types - Replies (1)

The rule says that the plain char should only be used to store character values.

C standards says single character constant for eg. 'X' are int not char. So the following code:

char x = 'A';

is a violation of the rule as in this char x is storing a constant whose type is "int". If this is not the violation then how to interpret this rule as the all single character constants are int according to "c" standards.

Print this item

  R.13.5 When does a function have persistent side effects
Posted by: misra-c - 27-03-2015, 01:28 PM - Forum: 8.13 Side effects - Replies (1)

Consider the following example:

Code:
bool fn ( int x )
{
   static int y;
   if ( x > 0 )
   {   y = x;  }  /* causes persistent side effect if reached */
   return ....
}

void call ( bool flag )
{
    if ( flag &&  fn(-3) ) /* Does RHS contain persistent side effect ? */
    { .... }
}
In this example the call of "fn(-3)" never executes the code "y=x" and therefore no persistent side effect will occur.
Is this a violation of rule 13.5?

Print this item

  Clarification on rule 10.6
Posted by: anuj1085 - 24-03-2015, 10:23 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

Is the rule only applies to "u" suffix or this rule also applies to "UL", "L" and other suffixes

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 75 online users.
» 0 Member(s) | 71 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: 539