From: "Michael S. Tsirkin" <mst@redhat.com>
To: Colin King <colin.king@canonical.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jorgen Hansen <jhansen@vmware.com>,
Adit Ranadive <aditr@vmware.com>,
George Zhang <georgezhang@vmware.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Julia Lawall <julia.lawall@lip6.fr>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][V2] VSOCK: remove unnecessary ternary operator on return value
Date: Thu, 30 Mar 2017 16:22:05 +0300 [thread overview]
Message-ID: <20170330162154-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170329153355.17525-1-colin.king@canonical.com>
On Wed, Mar 29, 2017 at 04:33:55PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.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@canonical.com>
Acked-by: Michael S. Tsirkin <mst@redhat.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
next prev parent reply other threads:[~2017-03-30 13:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 15:33 [PATCH][V2] VSOCK: remove unnecessary ternary operator on return value Colin King
2017-03-29 18:35 ` Stefan Hajnoczi
2017-03-30 13:18 ` Jorgen S. Hansen
2017-03-30 13:22 ` Michael S. Tsirkin [this message]
2017-03-30 18:07 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170330162154-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=aditr@vmware.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=georgezhang@vmware.com \
--cc=jhansen@vmware.com \
--cc=julia.lawall@lip6.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).