[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' inst
From: |
Eduardo Habkost |
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 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
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
- [Qemu-devel] [RFC 12/15] error: Make IGNORED_ERRORS not a NULL pointer, (continued)
- [Qemu-devel] [RFC 12/15] error: Make IGNORED_ERRORS not a NULL pointer, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 13/15] rdma: Simplify var declaration to avoid confusing Coccinelle, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 04/15] [coccinelle] Use IGNORE_ERRORS instead of NULL as errp argument, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 14/15] [coccinelle] Eliminate unnecessary local_err/error_propagate() usage, Eduardo Habkost, 2017/06/13
- [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/13
- Message not available
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/17
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Dr. David Alan Gilbert, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Peter Maydell, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eduardo Habkost, 2017/06/19
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments, Eric Blake, 2017/06/27
- Re: [Qemu-devel] [RFC 15/15] [test only] Use 'Error *err[static 1]' instead of 'Error **errp' to catch NULL errp arguments,
Eduardo Habkost <=
Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored, Eric Blake, 2017/06/27
Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored, Markus Armbruster, 2017/06/28
Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored, Daniel P. Berrange, 2017/06/29
Re: [Qemu-devel] [RFC 00/15] Error API: Flag errors in *errp even if errors are being ignored, Paolo Bonzini, 2017/06/29