All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26
Date: Mon, 17 Jul 2017 19:48:54 +0100	[thread overview]
Message-ID: <20170717184854.GC31820@work-vm> (raw)
In-Reply-To: <661f1ccf-6bba-7fd2-c0aa-e8b90066dad4@redhat.com>

* Eric Blake (eblake@redhat.com) wrote:
> On 07/17/2017 12:36 PM, Peter Maydell wrote:
> > On 17 July 2017 at 18:29, Eric Blake <eblake@redhat.com> wrote:
> >> On 07/17/2017 11:46 AM, Dr. David Alan Gilbert wrote:
> >>
> >>>> +++ w/hw/usb/bus.c
> >>>> @@ -407,8 +407,9 @@ void usb_register_companion(const char *masterbus,
> >>>> USBPort *ports[],
> >>>>  void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr)
> >>>>  {
> >>>>      if (upstream) {
> >>>> -        snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
> >>>> -                 upstream->path, portnr);
> >>>> +        int l = snprintf(downstream->path, sizeof(downstream->path),
> >>>> "%s.%d",
> >>>> +                         upstream->path, portnr);
> >>>> +        assert(l < sizeof(downstream->path));
> >>>
> >>> You may find this doesn't help in some windows builds;  the assert
> >>> functions aren't always marked as noreturn (because they pop up a dialog
> >>> that asks you whether you want to run into a debugger etc).
> >>
> >> How would it not help?  Are we using gcc 7 on windows builds?
> > 
> > At some point in the future we are likely to, because my
> > w32/w64 test setups use the Ubuntu gcc-mingw-w64-x86-64
> > packages, and so as I upgrade my desktop they will move
> > forward to newer gcc versions. (More generally our users
> > may do so before me ;-))
> 
> So, does gcc's warning actually depend on the no-return-ness of the
> assert() statement added here?

I'm not sure in this case, I'd hit it previously though, see my comment
from 2015 in:
   https://sourceforge.net/p/mingw-w64/bugs/306/

> Would there be anything wrong with making osdep.h do this on mingw:
> 
> #include <assert.h>
> #undef assert
> #define assert(expr) g_assert(expr)
> 
> so that we can reliably get no-return handling that we desire, without
> having to audit lots of other code?

It's a bit nasty, but hmm.
I only just about trust glib not to change, all of the fancier g_assert
variants can return, but g_assert is still safe.

Dave

> > 
> > We should be consistent -- if we can't trust assert() to
> > be marked nonreturn, as it seems we can't, then we shouldn't
> > write new code that assumes it always is, even if today
> > it doesn't happen to bite us on the compiler/host combinations
> > we're testing right now.
> 
> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
> 



--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2017-07-17 18:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-07 14:38 [Qemu-devel] Hacks for building on gcc 7 / Fedora 26 Dr. David Alan Gilbert
2017-04-07 19:21 ` Philippe Mathieu-Daudé
2017-07-13 13:07   ` Philippe Mathieu-Daudé
2017-07-17 13:42     ` Eric Blake
2017-07-17 13:48       ` Eric Blake
2017-07-17 14:16         ` Gerd Hoffmann
2017-07-17 15:04           ` Eric Blake
2017-07-17 16:46         ` Dr. David Alan Gilbert
2017-07-17 17:22           ` Peter Maydell
2017-07-17 17:29           ` Eric Blake
2017-07-17 17:36             ` Peter Maydell
2017-07-17 18:10               ` Eric Blake
2017-07-17 18:48                 ` Dr. David Alan Gilbert [this message]
2017-07-18 15:04               ` Philippe Mathieu-Daudé
2017-07-18 15:10                 ` Eric Blake
2017-07-19  7:15                   ` Thomas Huth
2017-07-17 17:46             ` Dr. David Alan Gilbert
2017-07-18  7:23             ` Daniel P. Berrange
2017-07-18 12:35               ` Eric Blake
2017-07-18 12:56                 ` Daniel P. Berrange
2017-07-18 23:59         ` Richard Henderson
2017-07-19  0:34           ` Eric Blake
2017-04-12 23:54 ` no-reply
2017-07-20 10:50 ` Daniel P. Berrange
2017-07-20 12:10   ` Eric Blake
2017-07-20 16:15   ` Dr. David Alan Gilbert
2017-07-20 16:47     ` Daniel P. Berrange
2017-07-20 17:04       ` Dr. David Alan Gilbert
2017-07-20 17:06         ` Daniel P. Berrange
2017-07-20 18:36           ` Eric Blake

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=20170717184854.GC31820@work-vm \
    --to=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=kraxel@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.