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

Username
  

Password
  





  Rule 8.6: External declaration without definition
Posted by: Polyspacer - 16-06-2015, 12:10 PM - Forum: 8.8 Declarations and defnitions - Replies (1)

I have a header file MISRA_8.6.h, in which a variable is declared:

Code:
extern signed short int Variable;

And I have the corresponding c-file MISRA_8.6.c, which uses the variable as input.
Code:
#include "MISRA_8.6.h"

signed short int A;

void main(void)
{

    /*8.6*/
    A = Variable;
    
}

The c-file defining the variable is out of scope. Is rule 8.6 violated by this setting or is another rule 8.x violated?

Print this item

  Rule 5.4: Macro identifier
Posted by: Polyspacer - 16-06-2015, 12:01 PM - Forum: 8.5 Identifers - Replies (1)

I have a question regarding rule 5.4: Which of the following #defines is violating this rule?

Code:
#define  engine_exhaust_gas_temperature_high_raw     egt_r
#define  engine_exhaust_gas_temperature_high_scaled  egt_s

#define x 0
#define x 0

#ifndef ABCDE
#define DAI_AGK_SEC_1BIT_RAM_START
#endif

#ifndef FGHIJ
#define DAI_AGK_SEC_1BIT_RAM_START
#endif

unsigned long int A;
unsigned short int Con = 0;

void main(void)
{

    /*5.4*/
    #ifdef DAI_AGK_SEC_1BIT_RAM_START
    A = Con;
    #endif
    A = x;
    
}

The 1st and 2nd #define are similar to the example given in the MISRA-C guideline. Hence, the 2nd #define violates the rule.
The 3rd and 4th #define are identical. Therefore, the 4th #define violates the rule.
The 5th and 6th #define are identical as well. Does the 6th #define violate the rule? According to the glossary, the macro name is a macro identifier...

Print this item

  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

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 381 online users.
» 0 Member(s) | 379 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: 23
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 34
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 366
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 322
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,441
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,860
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,497
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,690
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,246
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 430