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

Username
  

Password
  





  Rule 19.11 clarification request
Posted by: rmgalles - 18-04-2007, 12:50 PM - Forum: 6.19 Preprocessing Directives - Replies (1)

As stated and taken literally, this rule might be interpreted as requiring all identifiers used in any preprocessing directive be derived from a previous #define (is this the meaning of \"macro identifier\")?

Instead, I understand the rule as only requiring all identifiers used in the controlling constant-expression of #if and #elif preprocessing directives to be defined before use (unless the identifier is used as the operand of the defined() operator). However, identifiers used in the replacement-list of a #define preprocessing directive need NOT be \"defined before use\" as they may be ordinary identifiers and not defined by any #define preprocessing directive.

Otherwise, the identifier in a #define preprocessing directive itself could technically be interpreted as not meeting this rule, as the identifier isn't fully defined until after the directive has been processed. Thus, the only practical preprocessing directives covered by this rule appear to be #if and #elif directives.


As such, the rule might be more clearly stated as:

Quote:All identifiers used in the controlling constant expression of #if or #elif preprocessing directives shall be #defined before use, unless the identifier is an operand of the defined() operator.

Is my understanding and restating of the rule correct? Or, does this rule actually expect every identifier, including those in every #define \"macro body\" (replacement-list) to be defined before use (by a previous #define)?

Print this item

  is 'Open C' 'MISRA C' compliant?
Posted by: mukesh - 13-04-2007, 05:05 AM - Forum: General Questions - Replies (1)

Hi friends,

my question is same as the subject line

is 'Open C' 'MISRA C' compliant?

thanks n regards
Mukesh

Print this item

  Initialize a tag?
Posted by: gs - 21-03-2007, 04:16 PM - Forum: General Questions - No Replies

1998 Rule 29 states, \"[i]t would be incorrect to initialize the tag with an initializer which did not match the structure declared for that tag.\"

What does it mean to \"initialize the tag\"?

Print this item

  Rule 45 and polymorphism
Posted by: jlb - 07-03-2007, 03:10 PM - Forum: 6.11 Pointer Type Conversions - Replies (3)

Hello,

I am new to MISRA-C rules and in the code I am working on, there this kind of constructs :

Code:
struct TPL_ACTION {
    tpl_action_func action;    /**<  action function pointer   */
};

typedef struct TPL_ACTION tpl_action;

and for instance :

Code:
struct TPL_TASK_ACTIVATION_ACTION {
    /*  base action           */
    tpl_action    b_desc;
    /*  task descriptor pointer     */
    tpl_task      *task;
};

typedef struct TPL_TASK_ACTIVATION_ACTION
tpl_task_activation_action ;

tpl_action is an abstract type (no instance) and tpl_task_activation_action is a concrete type.

The function pointed by action function pointer takes a tpl_action * and casts it to the appropriate concrete type.

I understand rule 45 disallows pointer type casting to avoid memory alignment problems but here the first member of the abstract type is of the same type as the first member of the concrete type.

Is it legal ?

Best regards

Print this item

  Casting a Float to a Signed Integer
Posted by: embedded.kyle - 05-03-2007, 10:04 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

I'm working with some legacy code and part of my job is to modify it to comply with the MISRA standard. A large portion of the code relies on macros such as this one:

[code]#define CURRENT_LARGE_SHIFT (18L)
#define CURRENT_LARGE_SCALE(v) (int32_t)(v * (1L

Print this item

  Other question about pointer to void
Posted by: fwamolina - 07-02-2007, 08:48 PM - Forum: 6.11 Pointer Type Conversions - Replies (1)

In misraC-2004 when starts section 6.11 - Pointer type Conversion says the following:

\"Conversions involving pointer types require an explicit cast except when:
The conversion is between a pointer to object an a pointer to void....\"

my question is if this example is compliance with that.

Code:
void func (void)
{
  void*          pt_V;
  uint8_t*       pt_A;
  uint32_t*      pt_B;

  .
  .
  .

  pt_V = pt_A;

  /* use pointer */

  pt_V = pt_B;

  /* use pointer */

  .
  .
  .
}

thank you.

Print this item

  Boolean Types
Posted by: djtachyon - 05-02-2007, 07:08 PM - Forum: 6.6 Types - Replies (1)

Just wondering what is the best way to define a boolean type for MISRA and most importantly what to define TRUE and FALSE as.

Some thoughts:

typedef unsigned char boolean_t
#define TRUE (0==0)
#define FALSE (!0)

Thanks.

Print this item

  MISRA C 2004 Compliance Matrix
Posted by: Anonymous - 11-01-2007, 09:32 AM - Forum: General Questions - Replies (1)

Is there a template of the required Compliance Matrix available?

I would like to see such a matrix include the rule synopsis as well as it's ID, so that it is easy to comprehend.

Having purchased the MISRA-C 2004 PDF, I find that it is protected such that I cannot copy the contents of Appendix A as a good starting point.

Regards
Dave Banham

Print this item

  Void Pointer Usage
Posted by: MikeS - 11-01-2007, 09:04 AM - Forum: 6.11 Pointer Type Conversions - Replies (1)

Hi,

I have a question regarding the use of Void pointers.

Rule 11.2 is the rule that applies (Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object or a pointer to void).

My first question is:
How do you define \"a pointer to object\"?
By this, do you mean structure, derived types?
I couldn't see any definition for this in the MISRA text.

My second question is:
This rule allows the conversion of a pointer from one type to void. (i.e. to a NULL_PTR to allow for error checking)
I think that this rule also prohibits the use of a defined void ptr, converting this to point to an array or other obect, is this correct?

i.e. the following is illegal:

void *pv_my_void_ptr = NULL_PTR;
u16 *pu16_my_int_ptr = (u16 *)pv_my_void_ptr;

As this would make the checking of alignment (i.e. Rule 11.4) impossible as well as hiding the original type pointed to?

Many Thanks for your consideration.

Mike.

Print this item

  Complementary documentation on MISRA Rules
Posted by: Nicolette MAZURIER - 11-12-2006, 11:07 AM - Forum: General Questions - No Replies

I am working as a Software Quality Engineer at Siemens VDO in France and we are currently trying to document the consequence(s) of not respecting each of the MISRA rules, in order to make our developers aware of the risk(s). Sometimes this task is quite easy and sometimes less. So I am looking for some documentation that could help us reaching our objective. Today we are still using MISRA 1998, so I am more interested in documents dealing with the correponding rules, but it would also help for the future if some documents on MISRA 2004 exist.

Thanks for Help,

NM

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,118
» Latest member: sarkermita
» Forum threads: 966
» Forum posts: 2,655

Full Statistics

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

Latest Threads
cvalue and constant integ...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
Yesterday, 04:53 PM
» Replies: 1
» Views: 145
Rule 6-2-3 and C++17 [[fa...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
Yesterday, 04:48 PM
» Replies: 1
» Views: 112
10.2.3 Amplification
Forum: 4.10 Declarations
Last Post: misra cpp
12-04-2024, 02:20 PM
» Replies: 1
» Views: 128
Rule 7.0.5 Example potent...
Forum: 4.7 Standard conversions
Last Post: misra cpp
12-04-2024, 01:54 PM
» Replies: 1
» Views: 117
Rule 0.2.4 non-compliant ...
Forum: 4.0 Language independent issues
Last Post: misra cpp
12-04-2024, 01:51 PM
» Replies: 1
» Views: 145
Further guidance on MISRA...
Forum: 8.10 The essential type model
Last Post: mshawa
09-04-2024, 02:29 PM
» Replies: 0
» Views: 57
MISRA AC SLSF:2023 AMD1
Forum: MISRA AC resources
Last Post: david ward
05-04-2024, 01:56 PM
» Replies: 0
» Views: 73
MISRA AC GMG:2023 release...
Forum: MISRA AC GMG discussions
Last Post: misra-ac
25-03-2024, 06:01 PM
» Replies: 2
» Views: 420
14.3 and enum constants i...
Forum: 8.14 Control statement expressions
Last Post: misra-c
24-03-2024, 01:08 PM
» Replies: 1
» Views: 328
0-1-8. Exception: empty i...
Forum: 6.0 Language independent issues (C++)
Last Post: vmuthusu
18-03-2024, 04:01 AM
» Replies: 3
» Views: 8,325