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

Username
  

Password
  





  ISR function prototype generates error message in QAC
Posted by: vignesh081191 - 10-09-2015, 01:25 PM - Forum: General Questions - No Replies

In our project, we are using atmel microcontroller attiny24A. We are doing static analysis for our single file source code using QAC version 8.0.

The interrupt header file is include in the source file for interrupt usage and we dont get any issue in that
#include

But
We are getting the following error in the declaration of ISR function prototype.
ISR(TIM0_COMPA_vect);
^
Err(9:0926) [S] Expected: ) ,.

Functionality wise the code is working fine. So we have no idea what the QAC is expecting whether it misunderstands the ISR or not?

help me out guys...

Print this item

  5.8 and external identifiers in different header file
Posted by: lovewar - 25-08-2015, 01:39 AM - Forum: 8.5 Identifers - Replies (1)

Would the following examples be non-compliant with rule #5.8?

Code:
/* file 1. h */
extern int32_t count;    
extern void foo(void);

/* file 2.h */
extern int32_t count;   // here
extern void zoo(void);

Print this item

  Rule 8.5 - #define with function code in header files
Posted by: reito - 18-08-2015, 02:47 PM - Forum: 6.8 Declarations and Definitions - Replies (1)

Hello,
I would like to confirm the following interpretation of the rule 8.5. The rule says that "Header files should be used to declare objects, functions, typedefs, and macros. Header files shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage."

I have seen a couple of alerts in code raised when the header file contains a macro that generates the "body of one function". My understanding is that this is the case where the "macro produces definitions of objects or functions", and that this is a violation to be corrected.

In a similar way, if the header file contains a #typedef for an struct, should it be considered a violation to this rule?

Thanks in advance.

Print this item

  Rule 8.10, I don't understand the Rationale
Posted by: fpeelo - 05-08-2015, 03:45 PM - Forum: 8.8 Declarations and defnitions - Replies (6)

The Rationale for rule 8.10 says that inline functions with external linkage are not to be used, because it is not defined whether the function will in fact be inlined, or the external definition will be called.

However, this is also not defined for static functions: "Making a function an inline function suggests that calls to the function be as fast as possible. The extent to which such suggestions are effective is implementation-defined." (I'm using a draft of the C99 standard, http://www.open-std.org/JTC1/sc22/wg14/w.../n1256.pdf and this is 6.7.4.5. Footnote 121 spells it out more clearly: "For example, an implementation might never perform inline substitution...".)

So the behaviour of static inline functions is undefined in the same way as inline functions with external linkage.

It has been suggested that inline functions defined in header files should be defined with static linkage. Paragraph 6.7.4.3 of the above pdf says external linkage cannot reference indentifiers with internal linkage, but paragraph 6.7.4.6 says that any function with internal linkage can be inlined. So if an inline function is declared static, it can have local static variables. But there will be a different instance of the inline function for each .c file which includes the header with the function's definition, and each would have its own static variables! Effectively, you have a function definition with a static variable, the value of which differs depending on where it is called from. This will surely be unexpected behaviour to some programmers, and is therefore dangerous.

Was this considered when specifying that all inline functions should be static? Or is the draft wildly different from the final C99 spec?

Print this item

  Unclear why this code is not compliant with rule 11.3
Posted by: m4l490n - 04-08-2015, 09:00 PM - Forum: 8.11 Pointer type conversions - Replies (2)

Hi everybody

I'm having a very hard time understanding why the following code gives me two errors regarding rule 11.3.

Code:
#define NUM_TASKS 3

typedef struct
{
  uint32_t *CpuUtilizationPercent;
  uint32_t *Counter;
  TaskParam_t *Params;
  TaskConfig_t *Tasks;
  uint8_t NumTasks;
} PPTS_Config_t;

static uint32_t PPTS_CpuUtilizationPercent;
static uint32_t PPTS_Counter;

static TaskParam_t TaskParams[NUM_TASKS];

static TaskConfig_t TaskConfig[NUM_TASKS];

const PPTS_Config_t CnfPPTS =
{
  &PPTS_CpuUtilizationPercent,
  &PPTS_Counter,
  TaskParams,  /* MISRA-C rule 11.3 violation */
  TaskConfig,   /* MISRA-C rule 11.3 violation */
  NUM_TASKS
};
And in both cases the error is: A cast shall not be performed between a pointer to object type and a pointer to a different object type

The thing here is that both TaskParams and TaskConfig are pointers of the same type that are the struct elements Params and Tasks. I don't understand how ---TaskConfig_t TaskConfig[NUM_TASKS]--- is different from ---TaskConfig_t *Tasks---. They seem similar to me, or, am I messign something?

Thank you very much for helping and I hope this could be explained because I'm really frustrated.

Regards.

Print this item

  Does constness count as a type difference in rule 11.2?
Posted by: fpeelo - 23-07-2015, 03:55 PM - Forum: 8.11 Pointer type conversions - Replies (2)

I have an incomplete struct type, as per Directive 4.8. I declare types for pointers to the hidden struct:

typedef struct s_EthBuf *TEthBuf;
typedef struct s_EthBuf const *CTEthBuf;

The actual type, and an instance of the type, are declared in the translation unit that also defines the functions which operate on it.

Some functions need to modify the contents of the object, so they take a parameter of type TEthBuf. Some do not; they take a parameter of type CTEthBuf.

PC-Lint tells me that assigning a TEthBuf pointer to a variable of type CTEthBuf, or const TEthBuf, or passing it to a function which takes CTEthBuf as its parameter type, violates rule 11.2.

So: if I have struct s_EthBuf X then the following get the warning the 11.2 is violated:
CTEthBuf a = X;
const TEthBuf b = X;
foo(x)
- where foo is declared as void foo(CTEthBuf buf);

But it's OK to do
TEthBuf c = X;

But the type is the same, it's just that foo() doesn't change anything in the object.

Is PC-Lint correct here, when it believes that the types are different from the point of view of rule 11.2?

Print this item

  Any upcoming releases for MISRA C++ ?
Posted by: daniel tuchscherer - 21-07-2015, 09:53 AM - Forum: C++ General - Replies (5)

Hi,

As far as I know the latest guideline for C++ is MISRA C++ 2008. According to the current Cpp conferences and its talks about modern C++, the increasing use of embedded linux and during some research C++11 / C++14 both provide many techniques that could be useful for embedded programming of safety critical systems. Please correct me if I'm wrong. To name a few features there are std::array, range-loops, constexpr, static_assert, enum class.

Are there any upcoming MISRA C++ guidelines planned in the near future covering those (C++11, …) standards ?

Thanks Daniel

Print this item

  10.1 violated
Posted by: minnu - 08-07-2015, 05:34 AM - Forum: 6.6 Types - Replies (1)

#define NUM 9u
#define NUM2 8


/* gus32cmd is keyboard entry .numbers from 1 to 10*/

scanf("%d", &gus32cmd );

Switch(gus32cmd)
{
case:NUM
....
....
break;


case NUM2
..
..
break;

}

At lines case:NUM and case NUM2 I got following misra c error

"Rule 10.1 violated "implicit conversion of complex integer expression to a small sized integer is not allowed"
What correction I should do to avoid this error

Print this item

  14.3 and do-while within logical-and operator
Posted by: lovewar - 06-07-2015, 05:58 AM - Forum: 8.14 Control statement expressions - Replies (4)

Would the following example be compliant with rule #14.3?

Code:
do {
     // code..
} while ( (s8a < 10) && (s8a > 20) );  /* is && operator an essentially boolean controlling expression ? */

Print this item

  8.3 and parameter name omitted.
Posted by: lovewar - 01-07-2015, 07:29 AM - Forum: 8.8 Declarations and defnitions - Replies (2)

Would the following examples be compliant with rule #8.3?

Code:
-- in t1.h
extern int foo(int);

-- t2.c
#include "t1.h"

int foo(int value) {  // here(parameter name do not match)
}

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 369 online users.
» 0 Member(s) | 367 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: 364
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 320
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,440
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,245
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 429