01.07.2016 Views

SEI CERT C Coding Standard

tqcylJ

tqcylJ

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Declarations and Initialization (DCL) - DCL36-C. Do not declare an identifier with conflicting linkage classifications<br />

3.3.2 Compliant Solution<br />

This compliant solution does not include conflicting definitions:<br />

int i1 = 10; /* Definition, external linkage */<br />

static int i2 = 20; /* Definition, internal linkage */<br />

extern int i3 = 30; /* Definition, external linkage */<br />

int i4; /* Tentative definition, external linkage */<br />

static int i5; /* Tentative definition, internal linkage */<br />

int main(void) {<br />

/* ... */<br />

return 0;<br />

}<br />

3.3.3 Risk Assessment<br />

Use of an identifier classified as both internally and externally linked is undefined behavior.<br />

Rule Severity Likelihood Remediation Cost Priority Level<br />

DCL36-C Medium Probable Medium P8 L2<br />

3.3.4 Related Guidelines<br />

MISRA C:2012<br />

Rule 8.2 (required)<br />

Rule 8.4 (required)<br />

Rule 8.8 (required)<br />

Rule 17.3 (mandatory)<br />

3.3.5 Bibliography<br />

[Banahan 2003]<br />

[ISO/IEC 9899:2011]<br />

[Kirch-Prinz 2002]<br />

Section 8.2, “Declarations, Definitions and Accessibility”<br />

6.2.2, “Linkages of Identifiers”<br />

<strong>SEI</strong> <strong>CERT</strong> C <strong>Coding</strong> <strong>Standard</strong>: Rules for Developing Safe, Reliable, and Secure Systems 42<br />

Software Engineering Institute | Carnegie Mellon University<br />

[DISTRIBUTION STATEMENT A] Approved for public release and unlimited distribution.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!