From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] checkpatch: Disallow glib asserts in main code
Date: Fri, 28 Apr 2017 14:45:32 +0100 [thread overview]
Message-ID: <20170428134532.GG2085@work-vm> (raw)
In-Reply-To: <20170428134230.GB11415@redhat.com>
* Daniel P. Berrange (berrange@redhat.com) wrote:
> On Thu, Apr 27, 2017 at 05:55:26PM +0100, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Glib commit a6a875068779 (from 2013) made many of the glib assert
> > macros non-fatal if a flag is set.
> > This causes two problems:
> > a) Compilers moan that your code is unsafe even though you've
> > put an assert in before the point of use.
> > b) Someone evil could, in a library, call
> > g_test_set_nonfatal_assertions() and cause our assertions in
> > important places not to fail and potentially allow memory overruns.
> >
> > Ban most of the glib assertion functions (basically everything except
> > g_assert and g_assert_not_reached) except in tests/
> >
> > This makes checkpatch gives an error such as:
> >
> > ERROR: Use g_assert or g_assert_not_reached
> > #77: FILE: vl.c:4725:
> > + g_assert_cmpstr("Chocolate", >, "Cheese");
>
> Or could we perhaps instead undo the damage via a hack like
>
> #define g_assert_cmpint g_assert_cmpint_orig
> #define g_assert_cmpint(x, y, z) \
> g_assert_cmpint_orig(x, y,x); \
> abort()
I'd be kind of OK adding a q_assert_cmpint if you wanted,
but I think we shouldn't change the semantics of a public
name.
Dave
>
> Regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-04-28 13:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 16:55 [Qemu-devel] [PATCH] checkpatch: Disallow glib asserts in main code Dr. David Alan Gilbert (git)
2017-04-28 13:23 ` Paolo Bonzini
2017-04-28 13:34 ` Markus Armbruster
2017-04-28 13:46 ` Peter Maydell
2017-04-28 15:05 ` Eric Blake
2017-04-28 13:42 ` Daniel P. Berrange
2017-04-28 13:45 ` Dr. David Alan Gilbert [this message]
2017-04-28 15:10 ` Daniel P. Berrange
2017-04-28 15:27 ` 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=20170428134532.GG2085@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).