From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2185 invoked by alias); 23 May 2003 20:17:18 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 32264 invoked from network); 23 May 2003 20:16:03 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.131) by sources.redhat.com with SMTP; 23 May 2003 20:16:03 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 5BF8F2B2F; Fri, 23 May 2003 16:15:56 -0400 (EDT) Message-ID: <3ECE817C.1020900@redhat.com> Date: Fri, 23 May 2003 20:17:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Theodore A. Roth" Cc: gdb@sources.redhat.com Subject: Re: suggested compile warnings References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-05/txt/msg00321.txt.bz2 > 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 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