Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  1. Do not use identifiers that are already declared
    1. e.g., don't name a variable errno
  2. Do not pass functions invalid values
  3. For floating point exception functions, only pass 0 or bitwise OR of floating point macros
  4. Do not modify the string returned by setlocale() or localeconv()
  5. Do not call setjmp() in stupid places (eg. header files)
  6. Do not call longjmp() before calling setjmp()
  7. Do not call va_start() with a parameter declared with the register storage class, of array type, or a type that isn't compatible with the type after default argument promotions
  8. Do not try to get the address constant of a bit-field
    1. e.g., do not: &(t.member-designator)
  9. When functions fail, data structures often have indeterminate contents
    1. e.g., wcsxfrm(), wcsftime(), mbrtowc(), wcrtomb(), strxfrm(), strftime()
  10. Do not mismatch multibyte conversion states with character sequences in another state
  11. Do not change the LC_CTYPE in between calls to character conversion functions
  12. Only pass functions the type they ask for
    1. We might already have a rule for this, but I couldn't find it
  13. If the result of a function cannot be represented, the behavior is undefined
    1. e.g., abs(), labs(), llabs(), div(), ldiv(), lldiv().
  14. Do not cast a void expression to another type.
  15. Ensure expressions are compatible with the return types of the functions they call.
  16. Source files should always have a trailing newline.
  17. Constant expressions must consist entirely of constant components.
  18. Do not access anything through an address constant.
  19. Do not declare a function with a type qualifier
  20. Do not declare an integer constant macro with a non-integer value, or one out of limits
  21. Do not use inconsistent comparison functions
  22. Do not use bsearch() on an array not in the proper order
  23. In a header name, do not have the characters ', \, ", //, or /* in between the < and > or the characters ', \, //, or /* in between the quotes.
  24. Do not compare pointers that point to different objects.
  25. Do not have operations with side effects within an initialization list.