Fundamental Data


Numbers in General

  • Does the code avoid magic numbers?
  • Does it anticipate divide-by-zero errors?
  • Are type conversions obvious?
  • If variables with two different types are used in the same expression, will the expression be evaluated as it's intended to be?
  • Does the code avoid mixed-type comparisons?
  • Does the program compile with no warnings?

Integers

  • Do expressions that use integer division work the way they're intended to?
  • Do integer expressions avoid integer overflow problems?

Floating Point

  • Does the code avoid additions and subtractions on pairs of numbers with big differences?
  • Does the code systematically prevent rounding errors?
  • Does it avoid comparing floating-point numbers for equality?

Characters and Strings

  • Does the code avoid magic characters and strings?
  • Are references to strings free from off-by-one errors?
  • Does C code treat string pointers and character arrays differently?
  • Does C code follow the convention of declaring strings to be length constant+1?
  • Does C code use arrays of characters rather than pointers, when appropriate?
  • Does C code initialize strings to NULLs to prevent endless strings?
  • Does C code use strncpy() rather than strcpy()? Also strncat() and strncmp()?

Boolean Variables

  • Does the program use additional boolean variables to document conditional tests?
  • Does the program use additional boolean variables to simplify conditional tests?

Enumerated Types

  • Does the program use enumerated types instead of named constants for their improved readability, reliability, and modifiability?
  • Does the program use enumerated types instead of boolean variables for improved readability and flexibility?
  • Do tests using enumerated types test for invalid values?
  • Is the first entry in an enumerated type reserved for "invalid"?
  • Named Constants
  • Does the program use named constants in data declarations?
  • Have named constants been used consistently rather than using named constants in some places, literals in others?

Arrays

  • Are all array indexes within the bounds of the array?
  • Are array references free of off-by-one errors?
  • Are all subscripts on multi-dimensional arrays in the correct order?
  • In nested loops, is the right variable used as the array subscript, avoiding loop-index crosstalk?

Pointers

  • Are pointer operations isolated in functions?
  • Are pointer references valid or could the pointer be dangling?
  • Does the code check pointers for validity before using them?
  • Is the variable the pointer references checked for validity before it's used?
  • Are pointers set to NULL or NIL after freeing them?
  • Does the code use all the pointer variables required for the sake of readability?
  • Are pointers in linked lists freed in the right order?
  • Does the program allocate a reserve parachute of memory so that it can shut down gracefully if it runs out of memory?
  • Are pointers used only as a last resort, when no other method is available?