Re: [BUG] Using '%' on wiznet

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 09/21/02


On Fri, Sep 20, 2002 at 08:24:05PM -0700, George Greer wrote:
>On Fri, 20 Sep 2002, Mike Stilson wrote:
>-Wformat=2,
>
>As far as my GCC document says, -Wformat doesn't take an argument.  I
>haven't tried giving it one.

gcc (GCC) 3.2

from "info gcc"
under _Warning Options_
...
          -Wdisabled-optimization  -Wdiv-by-zero  -Werror
          -Wfloat-equal  -Wformat  -Wformat=2
          -Wformat-nonliteral  -Wformat-security
          -Wimplicit  -Wimplicit-int
...

and

`-Wformat'
     Check calls to `printf' and `scanf', etc., to make sure that the
     arguments supplied have types appropriate to the format string
     specified, and that the conversions specified in the format string
     make sense.  This includes standard functions, and others
     specified by format attributes (*note Function Attributes::), in
     the `printf', `scanf', `strftime' and `strfmon' (an X/Open
     extension, not in the C standard) families.

     The formats are checked against the format features supported by
     GNU libc version 2.2.  These include all ISO C89 and C99 features,
     as well as features from the Single Unix Specification and some
     BSD and GNU extensions.  Other library implementations may not
     support all these features; GCC does not support warning about
     features that go beyond a particular library's limitations.
     However, if `-pedantic' is used with `-Wformat', warnings will be
     given about format features not in the selected standard version
     (but not for `strfmon' formats, since those are not in any version
     of the C standard).  *Note Options Controlling C Dialect: C
     Dialect Options.

     `-Wformat' is included in `-Wall'.  For more control over some
     aspects of format checking, the options `-Wno-format-y2k',
     `-Wno-format-extra-args', `-Wformat-nonliteral',
     `-Wformat-security' and `-Wformat=2' are available, but are not
     included in `-Wall'.


>>-Wformat-security, -Wformat-nonliteral aren't in -Wall. along with a
>>couple others (extra args and y2k I believe.)
>
>Never said they were.  I made up a Makefile with every GCC warning to run
>CircleMUD through. There are quite a few useful ones not in -Wall.

I did the same.
About 50 lines of "MYFLAGS +="

But just to state, back into this thread:
format errors like the one originally mentioned aren't caught by
-Wformat (which IS included in -Wall).  You need to explicitly add
-Wformat=2 or -Wformat-security to get these warnings.

(summarizing "info gcc")
If -Wformat is used, you can also then specify -Wformat-security.

-Wformat=2 (Odd format, it's NOT an option AFAICT, but that IS the
argument) enables -Wformat and -Wformat-security and
-Wformat-nonliteral.

In a nutshell,
if you have:

const char *OK="Okay";
send_to_char(ch, OK);
-Wformat
no warning/msg.
-Wformat-security
no warnings/msg.
-Wformat-nonliteral
Complains about it there not being a constant format arg.

(From quick memory from having played with the flags, I didn't try this
out, but can do it real quick if it's that big of a deal.)



>George Greer

-Mike

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT