All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 8/9] Add more format string warning flags
Date: Mon, 2 Apr 2012 15:22:11 +0100	[thread overview]
Message-ID: <20120402142211.GH19259@redhat.com> (raw)
In-Reply-To: <CAFEAcA88n_OrBzT83sUS8-p=wGK+PE3xtS5NajN3kx0XaXefNg@mail.gmail.com>

On Mon, Apr 02, 2012 at 03:04:54PM +0100, Peter Maydell wrote:
> On 2 April 2012 13:17, Daniel P. Berrange <berrange@redhat.com> wrote:
> > On Mon, Apr 02, 2012 at 01:13:56PM +0100, Peter Maydell wrote:
> >> On 2 April 2012 11:50, Daniel P. Berrange <berrange@redhat.com> wrote:
> >> > +#if defined __GNUC__
> >> > +# define GCC_WARNINGS_SAVE      _Pragma("GCC diagnostic push")
> >> > +# define GCC_WARNINGS_RESTORE   _Pragma("GCC diagnostic pop")
> >> > +# define DO_PRAGMA(x)           _Pragma(#x)
> >> > +# define GCC_WARNINGS_IGNORE(x) DO_PRAGMA(GCC diagnostic ignored x)
> >> > +#else
> >> > +# define GCC_WARNINGS_SAVE
> >> > +# define GCC_WARNINGS_RESTORE
> >> > +# define GCC_WARNINGS_IGNORE(x)
> >> > +#endif
> >>
> >> Do these pragmas work on all versions of gcc that we support?
> >> Google suggests that the push/pop ones are only gcc 4.6 or better,
> >> for example.
> >
> > Hmm, the gcc info pages didn't mention any version constraints, but I'll
> > investigate this
> 
> Having thought about it a little more, to be honest I'm not really
> convinced that we should have these anyway. Better just to not enable
> the format-nonliteral warning. (format-security should catch the cases
> we care most about anyway, I think.)

The -Wformat-security option can only catch problems if the format
string is a literal. eg so it'd miss this:

  void foo(void) {
     int notastring = 1;
     const char *format = "String is %s";

     sprintf(format, notastring);
  }

There are a handful of places in QEMU which do that with non-trivial
format strings & were easy to fix in this patch, which I think is a
worthwhile improvement. The cases in the *-user/strace.c file though
are not practical to fix, without significant re-design of the code
in question.

I'm fine if we just include those easy fixes, while leaving the actual
warning flag disabled for now - someone can revisit later if desired.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2012-04-02 14:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 10:50 [Qemu-devel] Fix enablement of some compiler warning flags & add some more Daniel P. Berrange
2012-04-02 10:50 ` [Qemu-devel] [PATCH 1/9] Move all compiler warning/optimization flags to the same place Daniel P. Berrange
2012-04-02 16:19   ` Stefan Weil
2012-04-02 10:50 ` [Qemu-devel] [PATCH 2/9] Fix checking for compiler flag support Daniel P. Berrange
2012-04-02 12:29   ` Peter Maydell
2012-04-02 16:28   ` Stefan Weil
2012-04-02 10:50 ` [Qemu-devel] [PATCH 3/9] Print out progress when checking compiler flags Daniel P. Berrange
2012-04-02 13:56   ` Peter Maydell
2012-04-02 14:00     ` Daniel P. Berrange
2012-04-02 16:31   ` Stefan Weil
2012-04-02 10:50 ` [Qemu-devel] [PATCH 4/9] Remove 4 MB stack frame usage from sheepdog Daniel P. Berrange
2012-04-02 10:50 ` [Qemu-devel] [PATCH 5/9] Add in a large number of extra GCC warnings Daniel P. Berrange
2012-04-02 10:50 ` [Qemu-devel] [PATCH 6/9] Fix bit test to use & instead of && and enable -Wlogical-op warning Daniel P. Berrange
2012-04-02 12:27   ` Peter Maydell
2012-04-02 16:02     ` Maksim Kozlov
2012-04-02 10:50 ` [Qemu-devel] [PATCH 7/9] Add -Wmissing-format-attribute & fix problems it finds Daniel P. Berrange
2012-04-02 12:49   ` Andreas Färber
2012-04-02 10:50 ` [Qemu-devel] [PATCH 8/9] Add more format string warning flags Daniel P. Berrange
2012-04-02 12:13   ` Peter Maydell
2012-04-02 12:17     ` Daniel P. Berrange
2012-04-02 14:04       ` Peter Maydell
2012-04-02 14:22         ` Daniel P. Berrange [this message]
2012-04-02 14:32           ` Peter Maydell
2012-04-02 14:34             ` Daniel P. Berrange
2012-04-02 10:50 ` [Qemu-devel] [PATCH 9/9] Add note about some other options potentially worth enabling Daniel P. Berrange
2012-04-02 16:48   ` Stefan Weil

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=20120402142211.GH19259@redhat.com \
    --to=berrange@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.