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

Username
  

Password
  





  16.9 Reference to function pointer or not
Posted by: hele - 05-06-2012, 07:55 AM - Forum: 6.16 Functions - Replies (1)

Code:
typedef void (*fp)(STATE_MACHINE *sm, EVENT input);
struct STATE_MACHINE_
{
  fp fp_cur_state;
};

void stm_Startup   (STATE_MACHINE *sm,  EVENT input);
Code:
STM_STATE_MACHINE *sm;
sm->fp_cur_state = &stm_Startup;
or
Code:
sm->fp_cur_state = stm_Startup;
??

I have two tools to check code for Misra C.
Checking version without & to the function pointer with Tastking I get the error:
Quote:MISRA-C rule 16.9 violation: [R] function calls with no parameters should have empty parentheses
What in fact means the exact rule (I guess):
Quote:MISRA-C rule 16.9 violation: [R] A function identifier shall only be used with either a preceding &, or with a parenthesised parameter list, which may be empty.

checking with PC-Lint with & I get
Quote:sm->fp_cur_state = &stm_Startup;
stateMachine.c 72 Warning 546: Suspicious use of &

What's right? I guess functionality should be the same in both cases.

Print this item

  13.5 Loop control expression inconsistencies
Posted by: Dinesh - 30-05-2012, 10:19 AM - Forum: 6.13 Control Statement Expressions - Replies (1)

Dear Misra Committee,

Going through the previous posts on the rule 13.5, I found an inconsistency between the answers given in:
1) http://www.misra.org.uk/forum/viewtopic.php?f=69&t=272
2) http://www.misra.org.uk/forum/viewtopic.php?f=69&t=874

In the first post, the following was posted:

Quote:...
Loop Control Variable is defined as any variable occurring in the first, second or third expressions.

Loop Counter is defined as a Loop Control Variable which is,
• Initialised in the first expression or Initialised prior to first expression;
• In the second expression, the operand of a relational operator (= ); Note (1)
• In the third expression, always incremented or decremented by a constant, or an expression which evaluates to the same value for the duration of the loop;
• Not modified in the body of the loop.
...
Note 1: The equality operators (==, !=) should not be used because termination of the loop may not occur.
...

In the second post, the following example was given and was confirmed to be compliant with MISRA C 13.5.

[code]
bool Test_Index(int32_t index, int32_t bound){
return (bool)(p

Print this item

  Pointer conversions (implicit, explicit, void)
Posted by: Gabe - 25-05-2012, 04:19 PM - Forum: 6.11 Pointer Type Conversions - Replies (1)

I would like to ask for some help interpreting MISRA-C:2004. I have a few very simple examples. Please confirm whether my observations below are correct.

1)
#include
void main(void) {
char* string = "Hello World!";
int* result = string;
printf("Result: %d\n", *result);
}

This code is not MISRA-C:2004 compliant, because the implicit pointer conversion is not legal ANSI C. Thus, it violates rule 1.1. Is this observation correct?

2)
#include
void main(void) {
char* string = "Hello World!";
int* result = (int*)string;
printf("Result: %d\n", *result);
}

This code is MISRA-C:2004 compliant. However, the explicit type cast to int* is a violation of advisory rule 11.4. Is this observation correct?

3)
#include
void main(void) {
char* string = "Hello World!";
void* void_ptr = string;
int* result = void_ptr;
printf("Result: %d\n", *result);
}

This code is MISRA-C:2004 compliant. It also does not violate advisory rule 11.4. Is this observation correct?

4)
#include
void main(void) {
char* string = "Hello World!";
void* void_ptr = (void*)string;
int* result = void_ptr;
printf("Result: %d\n", *result);
}

This code is MISRA-C:2004 compliant. However, it now does violate advisory rule 11.4 due to the use of the type cast operator. Is this observation correct?

I do not see how 3) is better than alternative 2) or 4) above. Double casting through void pointers does not seem to be safe practice. It hides the conversion intent, so it makes the code harder to read.

I understand that the main reason for allowing conversions to void pointers is due to legacy reasons (i.e. writing data to memory). Seeing that 11.4 is advisory, would it not be better to refer to "conversions" between different pointers to object, rather than "casting"?

Print this item

  meaning of 045G MISRA AC SLSF
Posted by: stefania.botta - 08-05-2012, 07:25 AM - Forum: MISRA AC SLSF discussions - Replies (1)

Hi,

I write you, because I can not understand the meaning of 045G MISRA AC SLSF. The doubt is this: the rule want there are no variables written when transitioning between any states, in any case (I think it is very strong as assertion). Or the rule is specific when you are using condition-action and transition-action (deviation from 043A MISRA AC SLSF) when transitioning between any states. Or is there another meaning for understanding this rule?
Could you give me more details about this rule?

Kind regards,
Stefania Botta.

Print this item

  Copyright
Posted by: Schmidt - 02-05-2012, 10:22 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Hello,
I want to use the Exemplar Suite for the validation of a static code analyzer. Is it allowed to use copies of some of the files in my validation documentation? The documentation is only for internal use.

Print this item

  MISRA controllability rationale
Posted by: Haasec - 01-05-2012, 11:43 AM - Forum: MISRA SA discussions - Replies (1)

Hello,
I found a reference on the internet yesterday that in '06 or '07 MISRA had created a technical report that helps an engineer classify controllability for ISO-26262. It also indicated that this report is free? I did look in the publications section but I didn't seem to find the technical report name that I found elsewhere on the internet. Could someone please provide some more detail on this report? I understand that the SAEJ2980 specification is in development but I can't wait for it at this time.


Regards,
Chad Haase

Print this item

  does MISRA C rule 15.0 apply to MISRA AC AGC?
Posted by: ggoulas - 27-04-2012, 10:04 AM - Forum: MISRA AC AGC discussions - Replies (1)

Hello,
The rule 15.0 that has been added in MISRA-C edition 2 as a required rule is not present in the MISRA AC AGC document.
Should it be ignored in the context of Auto Code?
If not, is it an OBL rule? a REC rule?
Regards,
G.Goulas.

Print this item

  19.13 and Assembly
Posted by: gs - 18-04-2012, 08:08 PM - Forum: 6.19 Preprocessing Directives - Replies (3)

Does the following code violate rule #19.13?

Code:
#define QWER { asm ASDF #$7F; }
In this case, "$" means "value" and "#" means "address of" and is not the pasting operator.

Print this item

  8.9 and 3rd party library code
Posted by: gs - 19-03-2012, 03:32 PM - Forum: 6.8 Declarations and Definitions - Replies (1)

Hi,
Does rule #8.9 apply to objects/functions declared in 3rd party library code?

Thanks

Print this item

  Need for Both C and C++ Guidelines?
Posted by: bmbrown - 05-03-2012, 04:10 PM - Forum: C++ General - No Replies

Do the C++ guidelines stand on their own or do the C++ guidelines assume that the C guidelines are being followed as well? Our source code is a mixture of C and C++, but it is compiled using a C++ compiler. We are trying to determine which guideline(s) we need to acquire licenses for.

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