Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: "Theodore A. Roth" <troth@openavr.org>
Cc: gdb@sources.redhat.com
Subject: Re: suggested compile warnings
Date: Fri, 23 May 2003 20:17:00 -0000	[thread overview]
Message-ID: <3ECE817C.1020900@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.53.0305231130230.32235@knuth.amplepower.com>

> Hi,
> 
> I've always been configuring gdb with --enable-gdb-build-warnings=-Werror
> and thought that there where a bunch of gcc compile warnings issued.
> Looking more closely at my builds, that doesn't seem to be true.
> 
> For my own apps, I like to use '-Wall -Werror' as it lets the compiler
> catch a lot of my stupid mistakes. I tried '-Wall -Werror' for gdb,
> but that seems to be too restrictive for gdb source.
> 
> Does anyone else compile gdb with any of the -W<foo> gcc options?
> Is there a recommended list of these which should be used?
> 
> For example, adding -Wunused (without -Werror), turns up 149 wanrings.
> Most are unused variables, some are static decl's for functions that
> aren't defined. Most if not all of these should be trivial to fix.

See: 13.4.3 Compiler Warnings
http://sources.redhat.com/gdb/current/onlinedocs/gdbint_13.html#SEC118

Instead of -Wunused, look at the individual -Wunused-function, 
-Wunused-variable, ...

Off hand, other intersting ones are:

-Wwrite-strings
It's just hard and really messy.   People occasionally chip away at the 
edges.  Last time I tried, I came across what appeared to be an 
effective xfree("string"), outch!

-W
More for the sign VS unsigned checks it throws up, but it throws up some 
non problems :-(

-Wswitch-default
-Wswitch-enum
-Wswitch-fallthrough (doesn't actually exist)
But that could be religious :-)

-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
But tread carefully, it tends to run a foul of head files.

The trick is to first identify warnings that add real value (-Wformat 
for instance is good++) and then ensure that the fix is not worse than 
the problem being identified (using a cast to hide a problem, for 
instance, isn't a good idea vis: xffree ((char *) "a string")).

I've appended an old list of the error counts for various flags that was 
generated by compiling all the cross targets on a Red Hat GNU/Linux 7.2 
system and then deleting duplicates (which GCC? I don't remember).

Have fun.
Andrew

     590 W
     217 Waggregate-return
     335 Wall
       8 Wbad-function-cast
       4 Wcast-align
     106 Wcast-qual
       4 Wchar-subscripts
       4 Wcomment
    2913 Wconversion
       4 Wdeprecated-declarations
       4 Werror
      11 Wfloat-equal
       4 Wformat-extra-args
       4 Wformat-nonliteral
       4 Wformat-security
       4 Wformat-y2k
       4 Wformat
     109 Wformat=2
       7 Wimplicit-function-declaration
       4 Wimplicit-int
       7 Wimplicit
       4 Wimport
       4 Winline
       4 Wlong-long
       6 Wmain
      20 Wmissing-braces
     314 Wmissing-declarations
      57 Wmissing-noreturn
     341 Wmissing-prototypes
       4 Wmultichar
      51 Wnested-externs
       5 Wpacked
     101 Wpadded
       4 Wparentheses
       4 Wpointer-arith
     356 Wredundant-decls
       4 Wreturn-type
     840 Wshadow
     340 Wsign-compare
      74 Wstrict-prototypes
      44 Wswitch
     488 Wtraditional
       4 Wtrigraphs
      26 Wundef
       4 Wuninitialized
       4 Wunknown-pragmas
     213 Wunreachable-code
      66 Wunused-function
       8 Wunused-label
    1420 Wunused-parameter
      12 Wunused-value
     200 Wunused-variable
     274 Wunused
    4421 Wwrite-strings



  reply	other threads:[~2003-05-23 20:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-23 19:09 Theodore A. Roth
2003-05-23 20:17 ` Andrew Cagney [this message]
2003-05-23 21:02   ` Theodore A. Roth
2003-05-23 21:17   ` David Carlton
2003-05-23 21:46     ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ECE817C.1020900@redhat.com \
    --to=ac131313@redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=troth@openavr.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox