Tag Archives: C Code

10 Questions when Reviewing Embedded Code

Design News posted a great article “10 Questions to Consider When Reviewing Code” and I’m just posting the list here. Follow the link for the full article with the details behind each question.

  1. Does the Program build without warnings?
  2. Are there any blocking functions?
  3. Are there any potential infinite loops?
  4. Should this function parameter be a const?
  5. Is the code’s cyclomatic complexity less than 10?
  6. Has extern been limited with a liberal use of static?
  7. Do all if…else if… conditionals end with an else? And all switch statements have a default?
  8. Are assertions and/or input/output checks present?
  9. Are header guards present?
  10. Is floating point mathematics being used?

My personal pet peeve is #3 – I am constantly reviewing that uses WHILE loops waiting for a hardware bit to change state. But what if the hardware bit is broken? Then the device is DEAD. Always have some sort of timeout and use a FOR loop instead of a WHILE loop. At least the code will move on and won’t be dead. Maybe it won’t work properly because of the broken hardware but at least the device can limp along.