The Sun C compiler has options:

  • -errtags=yes Display tags for each message
  • -errwarn=tag1,tag2,... Make the indicated warnings into errors
  • -erroff=tag1,... Suppress the indicated warnings

Unlike with GCC, enabling optimization doesn't seem to increase its ability to detect certain cases to warn about.

For new projects, it may make sense to start with "-errwarn=%all". For existing projects, incremental work on eliminating warnings may be more desirable.

Specific recommendations for the Kerberos project follow.

Don't make incompatible-type warnings into errors initially. We have too many relatively benign bugs of this form (char* vs void*, char* vs unsigned char*, char * vs char *[], mismatched qualifiers, etc), which we should clean up eventually, but we should focus on more serious problems first. Do review them for bugs that aren't so benign.

The errors reported from a build of a version of the krb5 tree with -erroff=%none are listed below. There aren't a lot; I assume the intent is to use lint for more detailed analysis of questionable stuff, and the compiler mainly to generate object code.

Make into errors:

  • E_INTEGER_OVERFLOW_DETECTED
  • E_NO_IMPLICIT_DECL_ALLOWED
  • E_NO_TYPE_FOR_OLDSTYLE_PARAM
  • E_MACRO_REDEFINED (trips on USE_KADM5_API_VERSION stuff)
  • E_EMPTY_TRANSLATION_UNIT
  • E_INIT_DOES_NOT_FIT

Eventually make errors, but initially just review by hand:

  • E_ARG_INCOMPATIBLE_WITH_ARG
  • E_ASSIGNMENT_TYPE_MISMATCH

Suppress?

  • E_LOOP_NOT_ENTERED_AT_TOP (Duff's device)

Unsure; review cases and decide:

  • E_STATEMENT_NOT_REACHED
  • E_INC_USR_INC_MAY_NOT_PORTABLE

Once we eliminate the cases generating some of the warnings, and
suppress select other warnings, turn all non-suppressed warnings into
errors.

Compared to GCC or lint, this won't catch a lot of potential issues.

  • No labels