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

Username
  

Password
  





  Rule 5.6 / Rule 5.7
Posted by: sparker - 20-07-2006, 03:48 PM - Forum: 6.5 Identifiers - Replies (2)

I'm confused by the difference between the two examples in these two rules. In R5.6 we're shown that it is ok to reuse the structure member identifier \"next\" since \"member names are less likely to be confused\", and in R5.7 we're shown that members of two different structure types cannot have the same name (\"speed\").

Is the intention that one deviates from R5.7 leaving R5.6 to catch the most important cases? If so that isn't very clear from the text.

(Overall I'd be surprised if anyone ever sticks to R5.7 since it means that every identifier in your program, even every local, has to differ from every other. That means no \"i\", \"j\", \"p\", \"speed\", \"rpm\", ..., \"index\", etc.)

Print this item

  Enumeration specifier
Posted by: fwamolina - 17-07-2006, 08:05 PM - Forum: 6.6 Types - Replies (3)

My question is if there are one or more errors in this code?????????

Code:
/* file.h */
typedef enum tagColor {
  Rojo,
  Azul,
  Verde,
  Negro,
  Blanco
} Colors_t;

/* file.c */
#include \"file.h\"

void main (void)
{
  U32          u32value01;
  U32          u32value02;
  U16          u16value;
  Colors_t     enumcolor;

  u32value01 = Rojo;
  u32value02 = Blanco + Negro;

  u16value = 2U;

  enumcolor = u16value;

}

Print this item

  Rule 8.11(req) - Clarification required
Posted by: Hammer - 10-07-2006, 12:46 PM - Forum: 6.8 Declarations and Definitions - Replies (1)

Dear Misra

I seek clarification on the particular meaning of this rule. From the rule statment I take it that everything declared at file scope and only used internally should have the static storage class specifier applied.

For example the following would be a violation, ignoring the violation of rule 8.7.

Code:
int32_t var=0; /*VIOLATION, static should be applied*/

int32_t main(void)
{
var++;
return(var);
}

however I take a different meaning from the additional description given. I feel it is more related to the mixing use of extern and static.

Code:
extern int32_t var1;
static int32_t var1=0; /*Violation??*/

I would like to know which violation represents the meaning of this rule.

Print this item

  10.3. Casting to a narrower type
Posted by: Hammer - 06-07-2006, 01:30 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (5)

Code:
(int16_t)(s32a * s32b) /*Compliant */

This example is found on page 45.

I would like clarification on how this can be compliant code without having to check whether the result of s32*s32 can fit into a short. is my understanding correct that the multiplication will take place as int32_t and then be casted to int16_t.

I would be grateful for some clarification on the topic.

Print this item

  MIRCA 2004 Rule 1.1
Posted by: vkmet - 04-07-2006, 08:23 AM - Forum: 6.1 Environment - Replies (1)

Hi,

MISRAC 2004 Rule 1.1 refers to the environment limits specified in section 5.2.4 of the ISO 9899:1990 standard.

According to this rule, should all the limits specified by this section be STRICTLY followed, or only the one limit on internal and extrenal identifier length be strictly followed (Rule 5.1). Is a piece of code having 128 nesting levels of blocks MISRAC compliant?

Also there is a mention of the need to have certain compiler extentions in the code. Is a piece of code, having certain compiler extentions MISRA compliant? Or is it upto the organisation to decide that?

Best Regards
Vkmet

Print this item

  This cast is not defined for pointers
Posted by: warawut - 04-07-2006, 03:59 AM - Forum: General Questions - No Replies

mda5tbl[] = { (u8)5,
(u8)9,
(void*)wsrid00 --> Warning No. 307 };

static void wsrid00(void)
{
u16 i;
wmsgo[4] = 0;
for(i=0; i

Print this item

  Rule 12.7 and underlying type
Posted by: aravind - 30-06-2006, 09:48 PM - Forum: 6.12 Expressions - Replies (1)

Hi,

Question on 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed

[code]int32_T var1[32];
uint16_T var2 = 5U;
int32_T var3 = var1[(var2 - 1)

Print this item

  Rule 10.6: \"u\" Suffix to all unsigned constants
Posted by: Manni - 26-06-2006, 08:43 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (5)

Hello

I have a disagreement with a supporter of a bigger MISRA-C:2004 rule checking tool.

He means, that the following is MISRA-C:2004 compliant :

Code:
void foo(UINT b)
{
UINT a;

a = b + 30;
}

I mean, it is not compliant . There must be \"u\"-Suffix:
Code:
void foo(UINT b)
{
UINT a;

a = b + 30[b]u[/b];
}

1. reason:
\"Rule 10.6 (required): A \"U\" suffix shall be applied to all constants of unsigned type.\"

I think, it is a clear case, when I read this rule. There is spoken from \"all\" constants of unsigned Type. So why there should be no \"u\" Suffix?




2. reason:

In \"Rule 10.1 (required):\" in MISRA-C:2004, are examples for this:

MISRA-C:2004 in Rule 10.1/10.2
Code:
... u8a + 5 /* not compliant */

... u8a + 5U /* compliant */



For me it is really a clear case, there must be a \"u\" suffix at the constant. But we need to clarify it, with an official answer for this tiny problem.

Thanks

Print this item

  question to examples of rule 6.12.2
Posted by: Manni - 23-06-2006, 01:30 PM - Forum: 6.12 Expressions - Replies (2)

Hi

In Rule 12.2

Quote:nested assignment statements
Assignments nested within expressions cause additional side effects. The best way to avoid any chance of this leading to a dependence on order of evaluation is to not embed assignments within expressions.

For example, the following is not recommended:
x = y = y = z / 3 ;
x = y = y++;

I don't understand, what could go wrong here:
1. x = y = y = z / 3 ;
2. x = y = y++;

If x = 1, y = 2, z = 3, I would say,

- for 1. the result for x is everytime 1
- for 2. the result for x is everytime 3

What could a compiler make different here?

thanks

Print this item

  Enumeration specifiers
Posted by: fwamolina - 20-06-2006, 05:25 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

My question is if the code bellow is not compliance with misrac-2004

uint16_t GetSpeed (void);
void IncreaseSpeed (void);
void DecreaseSpeed (void);
void GoodSpeed (void);

enum tagSPEED
{
Low,
Medium,
High
};

void main (void)
{
uint16_t uSpeed;

uSpeed = GetSpeed();

switch (uSpeed)
{
case Low:
IncreaseSpeed();
break;

case Medium:
GoodSpeed (void);
break;

case High:
DecreaseSpeed (void);
break;

default:
break;
}
}

Is there any solution for this case?


Normative reference:
Ansi-Iso-9899-1990 (6.5.2.2)
Misra-c2004 (6.10.3)

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,207
» Latest member: [email protected]
» Forum threads: 1,017
» Forum posts: 2,800

Full Statistics

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

Latest Threads
About MISRA-C 2023 Permit
Forum: General Questions
Last Post: misra-c
08-05-2025, 08:37 AM
» Replies: 1
» Views: 855
MISRA 2023 Test Suite
Forum: General Questions
Last Post: misra-c
08-05-2025, 08:35 AM
» Replies: 1
» Views: 815
Roadmap to c23 support
Forum: General Questions
Last Post: misra-c
08-05-2025, 08:34 AM
» Replies: 1
» Views: 238
Typo in Appendix C of MIS...
Forum: 8.10 The essential type model
Last Post: misra-c
08-05-2025, 08:21 AM
» Replies: 1
» Views: 206
Rule 7.0.5, example non-c...
Forum: 4.7 Standard conversions
Last Post: cgpzs
17-04-2025, 12:10 PM
» Replies: 0
» Views: 203
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 340
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 322
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 208
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: 232
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 319