[libvirt] [PATCHv2 28/27] build: avoid ATTRIBUTE_UNUSED in headers

Matthias Bolte matthias.bolte at googlemail.com
Wed Jul 13 13:42:08 UTC 2011


2011/7/9 Eric Blake <eblake at redhat.com>:
> The compiler might optimize based on our declaration that something
> is unused.

Can this actually happen? The unused marker only says that something
_might_ be unused. I don't think that a compiler can optimize
something based on this when it cannot actually prove that it is
really unused.

> Putting that declaration in the header risks getting
> out of sync with the actual implementation, so it belongs better
> only in the .c files.  We were mostly compliant, and a new syntax
> check will help us in the future.

This is a valid point.

> * cfg.mk (sc_avoic_attribute_unused_in_header): New syntax check.
> * src/nodeinfo.h (nodeGetCPUStats, nodeGetMemoryStats): Delete
> attribute already present in .c file.
> * src/qemu/qemu_domain.h (qemuDomainEventFlush): Likewise.
> * src/util/virterror_internal.h (virReportErrorHelper): Parameters
> are actually used by .c file.
> * src/xenxs/xen_sxpr.h (xenFormatSxprDisk): Adjust prototype.
> * src/xenxs/xen_sxpr.c (xenFormatSxprDisk): Delete unused argument.
> (xenFormatSxpr): Adjust caller.
> * src/xen/xend_internal.c (xenDaemonAttachDeviceFlags)
> (xenDaemonUpdateDeviceFlags): Likewise.
> Suggested by Daniel Veillard.
> ---
>
> As suggested here:
> https://www.redhat.com/archives/libvir-list/2011-July/msg00501.html
>
>  cfg.mk                        |    8 ++++++++
>  src/nodeinfo.h                |    4 ++--
>  src/qemu/qemu_domain.h        |    2 +-
>  src/util/virterror_internal.h |    8 ++++----
>  src/xen/xend_internal.c       |   12 +++++-------
>  src/xenxs/xen_sxpr.c          |    5 ++---
>  src/xenxs/xen_sxpr.h          |    3 +--
>  7 files changed, 23 insertions(+), 19 deletions(-)

ACK.

-- 
Matthias Bolte
http://photron.blogspot.com




More information about the libvir-list mailing list