[libvirt] [PATCH] virnetdev: fix some issues found by coverity and mingw builds
Eric Blake
eblake at redhat.com
Mon Feb 2 19:31:33 UTC 2015
On 02/02/2015 11:31 AM, Pavel Hrdina wrote:
> Commit e562a61a introduced new function to get/set interface state but
> there was misuse of ATTRIBUTE_NONNULL on non-pointer attributes and also
> we need to wrap that functions by #ifdef to not break mingw build.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> +++ b/src/util/virnetdev.c
> @@ -671,12 +671,23 @@ int virNetDevSetIFFlag(const char *ifname,
> *
> * Returns 0 in case of success or -1 on error.
> */
> +#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
> int virNetDevSetOnline(const char *ifname,
> bool online)
> {
>
> return virNetDevSetIFFlag(ifname, IFF_UP, online);
> }
This feels like it should be safe, except maybe for the fact that it
uses IFF_UP. Maybe we should wrap that under VIR_IFF_UP (defined to
IFF_UP when the #ifdefs are right, and to 0 otherwise), so that _only_
virNetDevSetIFFlag() has to have a counterpart definition, instead of
repeating lots of #ifdefs on all the callers.
> +++ b/src/util/virnetdev.h
> @@ -201,25 +201,23 @@ int virNetDevDelMulti(const char *ifname,
> ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
>
> int virNetDevSetIFFlag(const char *ifname, int flag, bool val)
> - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
> - ATTRIBUTE_RETURN_CHECK;
> + ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
Ack to the changes in this file, although I still think the virnetdev.c
changes can be made shorter.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150202/78d55900/attachment-0001.sig>
More information about the libvir-list
mailing list