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: <3658D20B-EBF9-48A2-95A7-026D36F18AF8@vmware.com>
Date:   Thu, 30 Mar 2017 13:18:10 +0000
From:   "Jorgen S. Hansen" <jhansen@...are.com>
To:     Colin King <colin.king@...onical.com>
CC:     "David S . Miller" <davem@...emloft.net>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Adit Ranadive <aditr@...are.com>,
        George Zhang <georgezhang@...are.com>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Julia Lawall <julia.lawall@...6.fr>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH][V2] VSOCK: remove unnecessary ternary operator on return
 value


> On Mar 29, 2017, at 5:33 PM, Colin King <colin.king@...onical.com> wrote:
> 
> 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 return the
> 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 | 22 +++++++---------------
> 1 file changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
> index 4be4fbbc0b50..10ae7823a19d 100644
> --- a/net/vmw_vsock/vmci_transport.c
> +++ b/net/vmw_vsock/vmci_transport.c
> @@ -96,31 +96,23 @@ static int PROTOCOL_OVERRIDE = -1;
> 
> static s32 vmci_transport_error_to_vsock_error(s32 vmci_error)
> {
> -	int err;
> -
> 	switch (vmci_error) {
> 	case VMCI_ERROR_NO_MEM:
> -		err = ENOMEM;
> -		break;
> +		return -ENOMEM;
> 	case VMCI_ERROR_DUPLICATE_ENTRY:
> 	case VMCI_ERROR_ALREADY_EXISTS:
> -		err = EADDRINUSE;
> -		break;
> +		return -EADDRINUSE;
> 	case VMCI_ERROR_NO_ACCESS:
> -		err = EPERM;
> -		break;
> +		return -EPERM;
> 	case VMCI_ERROR_NO_RESOURCES:
> -		err = ENOBUFS;
> -		break;
> +		return -ENOBUFS;
> 	case VMCI_ERROR_INVALID_RESOURCE:
> -		err = EHOSTUNREACH;
> -		break;
> +		return -EHOSTUNREACH;
> 	case VMCI_ERROR_INVALID_ARGS:
> 	default:
> -		err = EINVAL;
> +		break;
> 	}
> -
> -	return err > 0 ? -err : err;
> +	return -EINVAL;
> }
> 
> static u32 vmci_transport_peer_rid(u32 peer_cid)
> -- 
> 2.11.0
> 

Reviewed-by: Jorgen Hansen <jhansen@...are.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ