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

Username
  

Password
  





  Rule 15.2: MISRA warning is not generated
Posted by: vastrad - 27-09-2010, 10:47 AM - Forum: 6.15 Switch Statements - Replies (6)

Hi All,

The Rule 15.2 says:
"An unconditional break statement shall terminate every non-empty switch clause"
i.e. The last statement in every switch clause shall be a break statement, or if the switch clause is a compound statement, then the last statement in the compound statement shall be a break statement.

I understand this as:
"In a switch clause, whatever be the path traversed by the code, there shall be one break statement at the end of every path"

In a project I have the following code for which I am not getting any MISRA warning (for case 1). If my understanding is incorrect, then somebody please correct me.

Code:
switch (variable_1)
{
  case 0:
    {
        // some code here;
        break;
    }
  case 1:
    {
        // some code here;
        if (variable_2 == 0)
        {
            break;
        }
    }
    default:
        break;
}

Best Regards,
Vinay Vastrad

Print this item

  Rule 12.5: OR sequence without parentheses not compliant?
Posted by: pkrebs - 17-09-2010, 07:51 AM - Forum: 6.12 Expressions - Replies (4)

Hello,

I have a question regarding Rule 12.5: "The operands of a logical && or || shall be primary-expressions."

I often use constructs of the form "(condition1) || (condition2) || ... || (condition n)" to test for illegal values of a set of input parameters in functions (see example below), which should be compliant as far as I understand the rule text without the need of extra parentheses to group the conditions (parenthesised expression, sequence of only logical ||). However, my analysis tool (flexelint, v9.00e) complains about this construct ("non-primary expression"). Did I got something wrong about the definition of "primary expression" or is this a false positive?

Thanks in advance for any answers.

Example:

Code:
if ((start >= end) || (start > 7U) || (end > 8U))      /* raises rule violation */
{
    /* do something */
}
else
{
    /* do something different*/
}


if ((start >= end) || ((start > 7U) || (end > 8U)))      /* does not raise violation, note extra parentheses around second and third condition */
{
    /* do something */
}
else
{
    /* do something different*/
}

Print this item

  Violation for rule 109
Posted by: klaus83 - 07-09-2010, 02:57 PM - Forum: 6.18 Structures and Unions - Replies (3)

Hello everybody,

Does anybody know if rule 109: "Overlapping storage shall not be used" is violated by having two pointer variables pointing on the same address??
My automated MISRA checker only looks for union declarations and definitions when checking this rule.


Thanks,
Klaus

Print this item

  12.7 and narrowing signed integers
Posted by: tjotjos - 31-08-2010, 09:19 PM - Forum: 6.12 Expressions - Replies (2)

I have a question concerning Rule 12.7: Bitwise operators shall not be applied to operands whose underlying type is signed.

I need to transmit a 7-bit signed integer (values are restricted -64 - +63). My current method, shown below, seems to be inconsistent with 12.7.

Code:
int_8 s8a;
uint_8 u8b;
...
u8b = s8a & 0x7F;

Is the following an acceptable solution, or a violation of 10.1? Do I need to use a deviation here for the 7-bit integer?
Code:
int_8 s8a;
uint_8 u8b;
...
u8b = ((uint_8)s8a & 0x7F;

Thank you for your help!

Print this item

  Simulink window appearence
Posted by: ggentile - 30-08-2010, 04:18 PM - Forum: MISRA AC SLSF discussions - Replies (1)

Regarding rule SLSF-19. In our expirience forcing 100% zoom factor push the designer to increment the nesting level of subsystem.
We tought that the main driver is the capability to have a readable model in one window instead of 100% zoom factor.

May you provide us comment/expirience on this rule ? Or a different interpretation of the rule probably I'm wrong.

Giacomo

Print this item

  Example for 12.06 violates 2.3
Posted by: grafitemis - 23-08-2010, 04:36 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (3)

It seems that the comments in mc2_12.06.c violate Rule 2.3:
if ( mc2_1206_boolean_a & mc2_1206_boolean_b ) /* Not Compliant -
/* bitwise operation on boolean operands */
{
;
}

Regards,

Andreas

Print this item

  Rule 2.1
Posted by: Josef.Rieger - 19-08-2010, 08:15 AM - Forum: MISRA AC TL discussions - Replies (1)

Hello.
I am implementing an automated MISRA checker (MINT) and need some details regarding this rule.
Second part of rule 2.1 says "Furthermore, the signal name should be unique and not conflict with any other signal in the TargetLink model".
I am able to check this (only non-propagated labels included), however: what about library blocks? If a library block with at least one labelled line is used multiple times, then we have multiple signal lines labelled by the same label within the model.
I have also question: what is "TargetLink" model? Is it a Simulink model containing at least one TargetLink subsystem? Or is it the contents of TargetLink subsystem(s), no matter what is outside?
I would highly appreciate any comments.
Best regards,
Josef

Print this item

  Rule #3-2-3 and Forward Declarations?
Posted by: gs - 18-08-2010, 07:05 PM - Forum: 6.3 Basic concepts (C++) - Replies (4)

Does rule #3-2-3 prohibit the use of forward declarations in separate files? For example, if a file, a.h, contained "class B;" and another file, c.h, #include'd a.h and contained a definition for class D which contained "friend class B;", would the rule permit such?

Print this item

  Generalized Question about #12.6 and Preprocessor Directives
Posted by: gs - 17-08-2010, 05:39 PM - Forum: 6.12 Expressions - Replies (1)

Was advisory #12.6 intended to apply to preprocessor directives at all? I only ask because the text does not specify one way or the other.

Print this item

  12.6 for Preprocessor Directives?
Posted by: gs - 05-08-2010, 01:46 PM - Forum: 6.12 Expressions - Replies (3)

Was 12.6 intended to prohibit the use of the '!' operator on such code as

Code:
#if ! defined A
#endif
?

Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,208
» Latest member: jablodan
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 84 online users.
» 0 Member(s) | 80 Guest(s)
Applebot, 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: 185
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 316
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 297
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 196
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: 217
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: 179
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 285
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 221
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 279
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: 725