[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

changes to get rid of warnings



The changes to get rid of over 570 warning messages (I lost count) are
now in the CVS repository.  They've actually been in there since Friday
but I've spent a lot of time testing and getting rid of some other
compilation-related problems.  Please perform a cvs update.

I've tested the changes on the standard make targets (mash, smash,
import, megatools) with gcc (2.7.2.1, 2.7.2.3, 2.91.09, 2.91.66,
2.95.2) on Red Hat Linux (6.1, 6.2) and on FreeBSD (2.2.5, 2.2.6,
2.2.7, 3.3, 4.0, 4.1).  On anything else, you may still see some
warning messages.

Here are the comments I logged:

Many small changes have been made to eliminate compiler warning
messages.  Here is a summary of the most common problem areas:

1. Constant data should be declared const.
   static const char rcsid[] = "@(#) $Header$"; // ok
   static char rcsid[] = "@(#) $Header$";       // warning
   static const char *rcsid = "@(#) $Header$";  // warning

2. Members should be initialized in the order that they were declared.

3. Watch out for comparisons between signed and unsigned values.  A
   warning usually indicates that something needs to be declared
   differently.  Use casts only when needed.
   if (i < 0 || (size_t) i > sizeof(buffer)) return; // ok
   if (i < 0 || i > sizeof(buffer)) return;          // warning

4. Unused variables should be deleted.  If the unused variables are used
   by code that is commented out, the unused declarations should be
   commented out as well.

5. Unused arguments should be commented out.
   TclObject* create(int /* argc */, const char* const* /* argv */) { // ok
   TclObject* create(int argc, const char* const* argv) {             // warning

6. Unused debugging functions should be disabled with an #if or #ifdef.

From now on, all code that is checked in should compile cleanly with no
warning messages.  If you're not sure how to avoid a warning message,
just ask and we'll try to figure it out together.

Lloyd