lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <58DA899D.70209@bfs.de>
Date:   Tue, 28 Mar 2017 18:04:45 +0200
From:   walter harms <wharms@....de>
To:     Colin King <colin.king@...onical.com>
CC:     "David S . Miller" <davem@...emloft.net>,
        Jorgen Hansen <jhansen@...are.com>,
        Adit Ranadive <aditr@...are.com>,
        Julia Lawall <julia.lawall@...6.fr>,
        Stefan Hajnoczi <stefanha@...hat.com>, netdev@...r.kernel.org,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] VSOCK: remove unnecessary ternary operator on return
 value



Am 28.03.2017 17:54, schrieb Colin King:
> From: Colin Ian King <colin.king@...onical.com>
> 
> Rather than assign the positive errno values to ret and then
> checking if it is positive and flip the sign, just set ret to
> be the -ve errno value.
> 
> Detected by CoverityScan, CID#986649 ("Logically Dead Code")
> 
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
>  net/vmw_vsock/vmci_transport.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
> index 4be4fbbc0b50..a68cd6b0fb72 100644
> --- a/net/vmw_vsock/vmci_transport.c
> +++ b/net/vmw_vsock/vmci_transport.c
> @@ -100,27 +100,27 @@ static s32 vmci_transport_error_to_vsock_error(s32 vmci_error)
>  
>  	switch (vmci_error) {
>  	case VMCI_ERROR_NO_MEM:
> -		err = ENOMEM;
> +		err = -ENOMEM;
>  		break;
>  	case VMCI_ERROR_DUPLICATE_ENTRY:
>  	case VMCI_ERROR_ALREADY_EXISTS:
> -		err = EADDRINUSE;
> +		err = -EADDRINUSE;
>  		break;
>  	case VMCI_ERROR_NO_ACCESS:
> -		err = EPERM;
> +		err = -EPERM;
>  		break;
>  	case VMCI_ERROR_NO_RESOURCES:
> -		err = ENOBUFS;
> +		err = -ENOBUFS;
>  		break;
>  	case VMCI_ERROR_INVALID_RESOURCE:
> -		err = EHOSTUNREACH;
> +		err = -EHOSTUNREACH;
>  		break;
>  	case VMCI_ERROR_INVALID_ARGS:
>  	default:
> -		err = EINVAL;
> +		err = -EINVAL;
>  	}
>  
> -	return err > 0 ? -err : err;
> +	return err;
>  }
>  
>  static u32 vmci_transport_peer_rid(u32 peer_cid)


yes, but because there is nothing to do you could return directly
and forget about err.

note: why is there a MCI_ERROR_NO_MEM when you can map this to ENOMEM ?

re,
 wh


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ