Re: [PATCH] virnetdev: fix some issues found by coverity and mingw builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---

> +++ 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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]