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

Username
  

Password
  





  Rule 8.4: Prototype for function with internal linkage required?
Posted by: aletomm - 04-11-2015, 02:51 PM - Forum: 8.8 Declarations and defnitions - Replies (1)

Does MISRA-C 2012 mandate prototypes for functions with internal linkage?

While MISRA-C 2012 rule 8.4 is very explicit about prototypes for functions with external linkage, we have not found a corresponding rule for internally linked functions.

Our static analysis tool takes the simplistic approach that prototypes are required in any case due to MISRA-C 2004 8.1 rule. I like to challenge its reasoning.

Thanks.

Print this item

  5.5 and groups of preprocessing
Posted by: lovewar - 03-11-2015, 06:44 AM - Forum: 8.5 Identifers - Replies (1)

such as

Code:
#ifndef NO_TAG
static void log (const char *format, ...)
{
}
#else
#if defined(__STDC_VERSION__)
#define log(...) do { } while (0)    // here
#endif
#endif
and, the identifier(log) exists after preprocssing has been performed:
Code:
static void log (const char *format, ...)   // does it apply to #define log ?
{
}
I have a question regarding rule 5.5: does the function(log) apply to #define log ?

Print this item

  Rule 2.4 and tag used in typedef
Posted by: lovewar - 30-10-2015, 09:05 AM - Forum: 8.2 Unused code - Replies (2)

Would the following examples be compliant with rule #2.4?

Code:
typedef struct cood cood_t;
struct cood {                    // here,  is the tag "cood" compliant?
    uint8_t  id;
};

Print this item

  10.5 Iterating over an enum
Posted by: dermiem - 29-10-2015, 04:32 PM - Forum: 8.10 The essential type model - Replies (2)

I usually define a enum in a project specific H file, to represent a set of signals:
typedef enum {
ADC_VBAT
ADC_FEEDBACK,
ADC_VOLTAGE,

ADC_NUM_SIGNALS
} adc_t ;

And then in the reusable C file, iterate over the configured set of signals. For example, to set the initial value of the averaged signal:

uint8_t i ;

for (i=0U; i < (uint8_t) ADC_NUM_SIGNALS; i++)
{
AdcClearAverage((adc_t) i) ;
}

where AdcClearAverage takes a parameter of type adc_t.

But this now generates warning 10.5 as an unsigned type is being cast to an enum.
What is the correct way to iterate over an enumeration?

Print this item

  Rule 19.1 and assignment of one element of array
Posted by: lovewar - 29-10-2015, 05:41 AM - Forum: 8.19 Overlapping storage - Replies (1)

Would the following examples be compliant with rule #19.1?

Code:
int16_t a[20];
void g(void)
{
    int16_t *p = &a[0];
    int16_t *q = &a[0];
    *p = *q;              /* Compliant - exception 1 */
}
void f(void)
{
    int16_t *p = &a[0];
    int16_t *q = &a[1];
    *p = *q;                     // here, is it Compliant ?
}

Print this item

  Rule 10.3 Does exception 1 apply to case labels?
Posted by: grunwald - 15-10-2015, 12:30 PM - Forum: 8.10 The essential type model - Replies (2)

Rule 10.3 covers assignment (as defined in the glossary) and the conversion of the constant expression in case labels.

Exception 1 says "A non-negative integer constant expression of essentially signed type may be assigned to an object of essentially unsigned type if its value can be represented in that type."

Is this exception intended to be restricted to assignment; or does it also apply to case labels?

Code:
switch (u8a) // controlling expression is essentially unsigned
{
    case 1: break; // '1' is essentially signed; 10.3 violation?
    case 2: break;
    default: break;
}

Print this item

  10.3 and essential type of & expression
Posted by: lovewar - 15-10-2015, 05:54 AM - Forum: 8.10 The essential type model - Replies (1)

Would the following examples be compliant with rule #10.3?

Code:
void foo(void) {
  uint8_t u8a = getCode();
  
  sint32_t s32a = u8a & 0xFF;    // here
}

Would the following examples be non-compliant with rule #10.3?
Code:
void foo(void) {
  uint8_t u8a = getCode();
  
  uint8_t u8b = u8a & 0xFF;    // here
}

Print this item

  Rule 18.4, 10.1, and the "type" of pointer to object
Posted by: michael.metivier - 01-10-2015, 06:48 PM - Forum: 8.18 Pointers and arrays - Replies (1)

Within our development group, there has been some discussion as to whether or not the construction

Code:
void test(uint8_t * up)
{
    bool invalid = !up;
    ...
}
is valid with regard to the usage of '!' against a pointer. According to the 18.X rules, '!' is not disallowed for use on pointers, but the explanation of Rule 10.1 with regards to the appropriate essential type for use with '!' would indicate that, as a non-Boolean, its use on pointers should be disallowed.

Do pointers have an "essential type" under the essential type model and what is the correct interpretation in this case?

Print this item

  Rule 5.9 - Scope of uniqueness
Posted by: jade - 11-09-2015, 04:49 PM - Forum: 8.5 Identifers - Replies (2)

In Rule 5.9, the amplification says that the identifier name should be unique across all name spaces and translation units. This is an expansion of what's in the rule header, but is consistent with the purpose of the "Amplification" sections. However, the examples imply that identifiers can be unique if there is no linkage. Isn't this a contradiction?

Print this item

  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

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,207
» Latest member: MLBstubs
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

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