You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 52 Next »

Use type definitions (typedef) to improve code readability.

Noncompliant Code Example

The following declaration of the signal() function is difficult to read and comprehend.

void (*signal(int, void (*)(int)))(int);

Compliant Solution

This compliant solution makes use of type definitions to specify the same type as in the noncompliant code example.

typedef void (*SighandlerType)(int signum);
extern SighandlerType signal(
  int signum,
  SighandlerType handler
);

Risk Assessment

Code readability is important for discovering and eliminating vulnerabilities.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

DCL05-C

low

unlikely

medium

P2

L3

Automated Detection

Tool

Version

Checker

Description

LDRA tool suite

9.7.1

299 S
381 S

Fully implemented

Compass/ROSE

 

 

 

PRQA QA·C
Unable to render {include} The included page could not be found.
 Fully implemented

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

CERT C++ Secure Coding Standard: DCL05-CPP. Use typedefs to improve code readability

ISO/IEC 9899:2011 Section 6.7.8, "Type definitions"

ISO/IEC TR 24772 "BRS Leveraging human experience"

 


  • No labels