Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
langc
/* In another source file */
#include <string.h>
void copy(char *dst, const char *src) {
  if (strcpy(dst, src) == 0) {
    /* Report error */
  }
}
 
/* Copy prototype in scope in this source file  */
void copy(char *dst, const char *src);
 
void g(const char *s) {
  char buf[20];
  copy(buf, s); 
  /* ... */
}

...

Code Block
bgColor#FFCCCC
langc
/* In another source file */
void buginf(const char *fmt, ...) {
   /* ... */
}

/* In this source file --, no buginf prototype in scope */
void buginf();
 
void h(void) {
  buginf("bug in function %s, line %d\n", __func__, __LINE__);  /* Violation */
  /* ... */
}

...

Code Block
bgColor#FFCCCC
langc
/* In another source file */
 
long f(long x) {
  return x < 0 ? -x : x;
}

/* In this source file, -- no f prototype in scope */
 
int g(int x) {
  return f(x);  /* Violation */
}

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

EXP37-C

mediumMedium

probableProbable

highHigh

P4

L3

Automated Detection

ToolVersionCheckerDescription
Compass/ROSE  

Can detect some violations of this rule. In particular, it ensures that all calls to open() supply exactly two arguments if the second argument does not involve O_CREAT, and exactly three arguments if the second argument does involve O_CREAT

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

CC2.EXP37

Partially implemented

EDG   
Fortify SCA5.0  
GCC
Include Page
GCC_V
GCC_V
 

Can detect violation of this rule when the -Wstrict-prototypes flag is used. However, it cannot detect violations involving variadic functions, such as the open() example described earlier

LDRA tool suite

Include Page
LDRA_V
LDRA_V

41 D
98 S
170 S
496 S
576 S

Partially implemented
PRQA QA-C
Include Page
PRQA_V
PRQA_V
3001
0674(C)
Partially implemented

...