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

Compare with Current View Page History

« Previous Version 14 Next »

Use visually distinct identifiers to eliminate errors resulting from misrecognizing the spelling of an identifier during the development and review of code. Depending on the fonts used, certain characters are visually similar or even identical:

  • '1' (one) and 'l' (lower case el)
  • '0' (zero) and 'O' (capital o)

Do not define multiple identifiers that vary only with respect to one or more visually similar characters.

When using long identifiers, try to make the initial portions of the identifiers unique for easier recognition. This also helps prevent errors resulting from non-unique identifiers (DCL32-C. Guarantee identifiers are unique).

Risk Analysis

Failing to use visually distinct identifiers can result in the wrong variable being used, causing unexpected program flow.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

DCL02-A

1 (low)

1 (unlikely)

2 (medium)

P2

L3

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

References

[[ISO/IEC 9899-1999]] Section 5.2.4.1, "Translation limits"
[[MISRA 04]] Rule 5.1

  • No labels