From: walter harms <wharms@bfs.de>
To: Colin King <colin.king@canonical.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jorgen Hansen <jhansen@vmware.com>,
Adit Ranadive <aditr@vmware.com>,
Julia Lawall <julia.lawall@lip6.fr>,
Stefan Hajnoczi <stefanha@redhat.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] VSOCK: remove unnecessary ternary operator on return value
Date: Tue, 28 Mar 2017 18:04:45 +0200 [thread overview]
Message-ID: <58DA899D.70209@bfs.de> (raw)
In-Reply-To: <20170328155424.22873-1-colin.king@canonical.com>
Am 28.03.2017 17:54, schrieb Colin King:
> 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 set ret to
> be the -ve errno value.
>
> Detected by CoverityScan, CID#986649 ("Logically Dead Code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.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
next prev parent reply other threads:[~2017-03-28 16:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-28 15:54 [PATCH] VSOCK: remove unnecessary ternary operator on return value Colin King
2017-03-28 16:04 ` walter harms [this message]
2017-03-29 4:49 ` 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=58DA899D.70209@bfs.de \
--to=wharms@bfs.de \
--cc=aditr@vmware.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--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).