qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments
Date: Tue, 27 Jun 2017 18:31:27 -0300	[thread overview]
Message-ID: <20170627213127.GC12152@localhost.localdomain> (raw)
In-Reply-To: <aa23c822-0f0b-133f-fc45-9e344b8e3a93@redhat.com>

On Tue, Jun 27, 2017 at 03:12:25PM -0500, Eric Blake wrote:
> On 06/19/2017 08:26 AM, Eduardo Habkost wrote:
> 
> >> Is gcc's __attribute__((nonnull)) any better? It seems to apply
> >> to the whole function prototype rather than an individual argument
> >> though so probably not :-(
> > 
> > It's possible to specify which arguments are non-null with
> > nonnull(<arg-index>, ...).  It's harder to use, but probably more
> > Coccinelle-friendly.
> 
> Libvirt uses it, wrapped in a macro; for example:
> 
> int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
> virCPUDefCopyModel(virCPUDefPtr dst,
>                    const virCPUDef *src,
>                    bool resetPolicy)
> { ...
> 
> and at least Coverity is able to use that information (libvirt had
> problems in the past where older gcc _silently_ mis-optimized a program
> that used the attribute, and ended up having our macro defined only
> during Coverity and not during normal compilation; but I think that's
> finally been resolved now that newer gcc is saner in its behavior). I
> don't know how much smarts Coccinelle has for coming up with the right
> parameter number in an automated conversion patch, though.

In the worst case, the script could have a dozen transformations, one
transformation for each possible number of function arguments.

However, I hit this Coccinelle bug when trying to implement that:
https://github.com/coccinelle/coccinelle/issues/107

-- 
Eduardo

  reply	other threads:[~2017-06-27 21:31 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 16:52 [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored Eduardo Habkost
2017-06-13 16:52 ` [Qemu-devel] [RFC 01/15] tests: Test cases for error API Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 02/15] error: New IGNORE_ERRORS macro Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 03/15] Add qapi/error.h includes on files that will need it Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 04/15] [coccinelle] Use IGNORE_ERRORS instead of NULL as errp argument Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 05/15] qapi: Use IGNORE_ERRORS instead of NULL on generated code Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 06/15] test-qapi-util: Use IGNORE_ERRORS instead of NULL Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 07/15] Manual changes to use " Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 08/15] error: New ERR_IS_* macros for checking Error** values Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 09/15] [coccinelle] Use ERR_IS_* macros Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 10/15] test-qapi-util: " Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 11/15] Manual changes to use " Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 12/15] error: Make IGNORED_ERRORS not a NULL pointer Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 13/15] rdma: Simplify var declaration to avoid confusing Coccinelle Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 14/15] [coccinelle] Eliminate unnecessary local_err/error_propagate() usage Eduardo Habkost
2017-06-13 16:53 ` [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments Eduardo Habkost
     [not found]   ` <20170615121407.GA2399@work-vm>
2017-06-17 19:33     ` Eduardo Habkost
2017-06-19  8:48       ` Dr. David Alan Gilbert
2017-06-19  9:43         ` Peter Maydell
2017-06-19 13:26           ` Eduardo Habkost
2017-06-27 20:12             ` Eric Blake
2017-06-27 21:31               ` Eduardo Habkost [this message]
2017-06-27 20:22 ` [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored Eric Blake
2017-06-28  9:05 ` Markus Armbruster
2017-06-28 17:41   ` Eduardo Habkost
2017-06-29  6:54     ` Markus Armbruster
2017-06-29 12:57       ` Eduardo Habkost
2017-06-30 11:40         ` Markus Armbruster
2017-07-01 14:20           ` Eduardo Habkost
2017-07-03 12:51             ` Markus Armbruster
2017-07-01 14:29           ` Eduardo Habkost
2017-07-03 13:21             ` Markus Armbruster
2017-07-03 13:47               ` Eduardo Habkost
2017-06-29 14:01     ` Daniel P. Berrange
2017-06-29 13:39   ` Paolo Bonzini
2017-06-29 14:18     ` Daniel P. Berrange
2017-06-29 17:09       ` Eduardo Habkost
2017-06-29 17:38         ` Daniel P. Berrange
2017-06-29 17:47           ` Eduardo Habkost
2017-06-29 18:04             ` Daniel P. Berrange
2017-06-29 14:14   ` Daniel P. Berrange

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=20170627213127.GC12152@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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 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).