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

Username
  

Password
  





  12.1 and for-loops
Posted by: gs - 14-05-2008, 06:48 PM - Forum: 6.12 Expressions - Replies (2)

Given the code:

Code:
void f()
    {
    int i, j;
    for( i =0, j = 0; i < 10; i++, j++ ) {}
    }
does rule 12.1 'advise' (instead of 'require') I place '()' around the for-loop initializers? In other words, to what extent does this rule apply in the head of a for-loop? The precedence relied on is the precedence of the '=' operator with respect to the ',' operator.

Print this item

  12.6 boolean expression assigned to int example
Posted by: pkruk - 14-05-2008, 09:15 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Code:
uint16_t mc2_1206_x;
   uint16_t mc2_1206_y;
   uint16_t mc2_1206_z;
   mc2_1206_x = ( mc2_1206_y == mc2_1206_z ); /* Not compliant - mc2_1206_x is not effectively boolean */

This code has been marked as violation of rule 12.6 but I fail to see why. There are no (&&, || and !) operators so the first part of the rule does not apply. The boolean expression is used as operand of "=" so the second part of the rule is complied to as well.
Please correct me if I'm wrong.

Print this item

  Rule 12.2 and "nested assignment statements"
Posted by: pkruk - 14-05-2008, 07:42 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Example from mc2_1203.c:

Code:
mc2_1203_x = sizeof ( mc2_1203_a = 1234U );

Is this code also a violation of rule 12.2 "nested assignment statements"?

Print this item

  Rule 12.1 - are extra parentheses not compliant?
Posted by: pkruk - 13-05-2008, 02:36 PM - Forum: 6.12 Expressions - Replies (1)

Quote:However, do not add too many parentheses so as to clutter the code and make it unreadable.
Does it means that the "not required" parentheses below are a violation of this rule? If not, is there a case where too many parentheses is a violation to this rule?
Code:
x = a + b; /* acceptable */
x = (a + b); /* () not required */

Print this item

  Rule 8.3 - incorrect example or missing comment
Posted by: pkruk - 12-05-2008, 01:04 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Function declaration in mc2_0803.h:

Code:
extern void mc2_0803_2 ( my_s32bit_int param0803 );
Function definition in mc2_0803_2.c:
Code:
void mc2_0803_2 ( my_other_s32bit_int param0803 )

The types are different (different typedef names) - either there should be "Not Compliant" comment or the type should be changed.

Print this item

  Rule 19.9 - incorrect comment in mc2_1909.c?
Posted by: pkruk - 09-05-2008, 02:21 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

mc2_1909.c contains following code:

Code:
#define SUM(A,B,C) ((A) + (B) + (C)) /* Violates Rule 17.4 */

Rule 17.4 is "Array indexing shall be the only allowed form of pointer arithmetic." - the code does not seem to be violation of this rule.

Print this item

  Left Shifts and Castings
Posted by: gs - 05-05-2008, 07:33 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (2)

Is the following acceptable under 10.5?
[code]
unsigned char u = 1u;
(unsigned char) u

Print this item

  MISRA SA Errata
Posted by: david ward - 01-05-2008, 03:36 PM - Forum: MISRA SA resources - No Replies

Regrettably there are a few errata in MISRA SA, both in the print and PDF versions. The attached file contains the corrected pages and the errata are as follows:

  • Page 77 - Figure A.4 was missing the solid line around the air pipe and air spring (affects print version only)
  • Page 83 - Figure C.1, same issue (affects print version only)
  • Page 93 - Figure E.1, the third formula was incorrect and should read P(F|A) (affects both versions).
New PDF purchases have been corrected so the third issue is only present in PDFs purchased before 11 April 2008.



Attached Files
.pdf   MISRA SA Errata Apr 08.pdf (Size: 240.25 KB / Downloads: 12)
Print this item

  READ ME FIRST
Posted by: david ward - 01-05-2008, 03:31 PM - Forum: MISRA SA resources - No Replies

This area of the Forum provides downloadable resources associated with MISRA Publications.

Please note that by downloading a resource you accept the license conditions associated with it.

Further details are given with each file.

Print this item

  MISRA C++ launch
Posted by: david ward - 01-05-2008, 03:27 PM - Forum: C++ Announcements - No Replies

MISRA is pleased to announce that MISRA C++ will be published on 5 June 2008 and launched at the Safety-Critical Systems Club Tools Event in London on that date. Please see http://www.scsc.org.uk/diary.html?opt=detail&id=70 for details of the event and how to register.

A more in-depth workshop/tutorial session on MISRA C++ is planned for the MISRA Conference in late 2008 and further details will be available later in the year.

Copies of MISRA C++, in both hardcopy and PDF formats, will be available to purchase from the MISRA webstore after the launch date. Prices will be announced nearer the time. We regret that we cannot accept pre-orders for the document at this time.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,171
» Latest member: stephanmuench
» Forum threads: 998
» Forum posts: 2,752

Full Statistics

Online Users
There are currently 227 online users.
» 0 Member(s) | 225 Guest(s)
Bing, Google

Latest Threads
Rule 6.2.1: non-inline co...
Forum: 4.6 Basic concepts
Last Post: cgpzs
22-11-2024, 10:11 AM
» Replies: 0
» Views: 37
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 46
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 399
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 339
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,459
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,876
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,524
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,707
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,258
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 449