Skip to content

RULE-8-7: Flags functions that are called in only one unit, different than the unit it is defined in #864

Closed
@picardb

Description

@picardb

Affected rules

  • RULE-8-7

Description

The query flags all functions that are called in only one unit, even if that unit is not the one where the function is defined. Technically, if we understand the term "referenced" as "called", this would indeed be a violation of the rule. But according to a MISRA official in this forum post, "referenced" should also include the definition of the function.

Example

Example taken from the forum post mentioned above. Here, bar() is flagged as a violation of the rule even if it is called from main.c.

/* foo.h*/
#ifndef FOO_H
#define FOO_H

extern void foo(void);
extern void bar(void);

#endif

/* foo.c*/
#include "foo.h"

void foo(void)
{
}

void bar(void)
{
  foo();
}

/* main.c*/
#include "foo.h"

int main(void)
{
  bar();
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding Standards

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions