Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

...

Recommendation

Severity

Likelihood

Detectable

RepairableRemediation Cost

Priority

Level

DCL06-C

Low

Unlikely

Yes

NoMedium

P2

L3

Automated Detection

"#define" or enum constants should be used instead of hard coded values whenever possible

4400, 4401, 4402, 4403,

4404, 4405, 4406, 4408,

4409, 4414, 4415

Tool

Version

Checker

Description

Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC-DCL06
CodeSonar

Include Page
CodeSonar_V
CodeSonar_V

LANG.STRUCT.SW.SWNEE

Switch with non-enum expression

Compass/ROSE



Could detect violations of this recommendation merely by searching for the use of "magic numbers" and magic strings in the code itself. That is, any number (except a few canonical numbers: −1, 0, 1, 2) that appears in the code anywhere besides where assigned to a variable is a magic number and should instead be assigned to a const integer, enum, or macro. Likewise, any string literal (except "" and individual characters) that appears in the code anywhere besides where assigned to a char* or char[] is a magic string

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

CC2.DCL06

Fully implemented

Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C3120, C3121, C3122, C3123, C3131, C3132


Klocwork

Include Page
Klocwork_V
Klocwork_V

CERT.LITERAL.INT.CONST
CERT.LITERAL.FLT.CONST
CERT.LITERAL.STR.CONST
CERT.LITERAL.CHAR.CONST
CERT.LITERAL.BITFIELD
CERT.LITERAL.ARRAY


LDRA tool suite
Include Page
LDRA_V
LDRA_V

201 S

Fully implemented

Parasoft C/C++test
Include Page
Parasoft_V
Parasoft_V

CERT_C-DCL06-a

Use meaningful symbolic constants to represent literal values

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C: Rec. DCL06-C


Checks for:

  • Hard-coded buffer size
  • Hard-coded loop boundary

Size of memory buffer is a numerical value instead of symbolic constant

Loop boundary is a numerical value instead of symbolic constant

PRQA QA-C
Include Page
PRQA QA-C_vPRQA QA-C_v

3120, 3121, 3122,

3123, 3131, 3132

Partially implementedPRQA QA-C++
Include Page
cplusplus:PRQA QA-C++_Vcplusplus:PRQA QA-C++_V

Rec. fully covered.

Related Vulnerabilities

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

...