Re: [PATCH 4/5] Return bool in virNetDevFeatureAvailable

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

 



On Mon, Jun 06, 2016 at 09:39:27 +0200, Ján Tomko wrote:
> Simplify the logic
> ---
>  src/util/virnetdev.c | 27 ++++++++++++---------------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
> index 4705891..52f02d3 100644
> --- a/src/util/virnetdev.c
> +++ b/src/util/virnetdev.c
> @@ -3254,15 +3254,14 @@ struct ethtool_to_virnetdev_feature {
>  *
>  * Returns 0 if not found, 1 on success, and -1 on failure.

This is no longer valid after this patch.

>  */
> -static int
> +static bool
>  virNetDevFeatureAvailable(const char *ifname, struct ethtool_value *cmd)
>  {
> -    int ret = -1;
> -
>      cmd = (void*)cmd;
> -    if (!virNetDevSendEthtoolIoctl(ifname, cmd))
> -        ret = cmd->data > 0 ? 1 : 0;
> -    return ret;
> +    if (virNetDevSendEthtoolIoctl(ifname, cmd) == 0 &&
> +        cmd->data > 0)
> +        return true;
> +    return false;
>  }
>  
>  
> @@ -3307,12 +3306,12 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
>  
>      for (i = 0; i < ARRAY_CARDINALITY(ethtool_cmds); i++) {
>          cmd.cmd = ethtool_cmds[i].cmd;
> -        if (virNetDevFeatureAvailable(ifname, &cmd) == 1)
> +        if (virNetDevFeatureAvailable(ifname, &cmd))
>              ignore_value(virBitmapSetBit(bitmap, ethtool_cmds[i].feat));
>      }
>  
>      cmd.cmd = ETHTOOL_GFLAGS;
> -    if (virNetDevFeatureAvailable(ifname, &cmd) == 1) {
> +    if (virNetDevFeatureAvailable(ifname, &cmd)) {
>          for (i = 0; i < ARRAY_CARDINALITY(flags); i++) {
>              if (cmd.data & flags[i].cmd)
>                  ignore_value(virBitmapSetBit(bitmap, flags[i].feat));
> @@ -3332,15 +3331,13 @@ virNetDevGetEthtoolFeatures(virBitmapPtr bitmap,
>   *
>   * Returns 0 if not found, 1 on success, and -1 on failure.

Neither this.

>   */
> -static int

ACK with docs fixed.

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