From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/4] VMCI: Remove redundant error check
Date: Sat, 17 May 2014 19:54:11 +0000 [thread overview]
Message-ID: <20140517195411.GE15585@mwanda> (raw)
In-Reply-To: <1400350980-30455-1-git-send-email-peter.senna@gmail.com>
I like this. There is way too much code where it sets a variable and
then checks it again a couple lines down instead of just handling it
immediately so that every line is clear without having to keep track
so many variables.
But the automated patch doesn't really go far enough in cleaning up this
function.
On Sat, May 17, 2014 at 08:22:57PM +0200, Peter Senna Tschudin wrote:
> drivers/misc/vmw_vmci/vmci_context.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
> index f866a4b..3995e64 100644
> --- a/drivers/misc/vmw_vmci/vmci_context.c
> +++ b/drivers/misc/vmw_vmci/vmci_context.c
> @@ -836,12 +836,12 @@ int vmci_ctx_set_chkpt_state(u32 context_id,
> for (i = 0; i < num_ids && result = VMCI_SUCCESS; i++) {
This for loop is nonsense. Probably it was left over cruft. It should
be:
for (i = 0; i < num_ids; i++) {
> current_id = ((u32 *)cpt_buf)[i];
> result = vmci_ctx_add_notification(context_id, current_id);
> - if (result != VMCI_SUCCESS)
> + if (result != VMCI_SUCCESS) {
> + pr_devel("Failed to set cpt state (type=%d) (error=%d)\n",
> + cpt_type, result);
> break;
return result;
Why break when it's just going to return? Eliminate the need to track
this error.
> + }
> }
> - if (result != VMCI_SUCCESS)
> - pr_devel("Failed to set cpt state (type=%d) (error=%d)\n",
> - cpt_type, result);
>
> return result;
return VMCI_SUCCESS;
Then we can remove the initialization for "result" as well to eliminate
another forced look up to the start of the function and down.
regards,
dan carpenter
prev parent reply other threads:[~2014-05-17 19:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 18:22 [PATCH 1/4] VMCI: Remove redundant error check Peter Senna Tschudin
2014-05-17 19:54 ` Dan Carpenter [this message]
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=20140517195411.GE15585@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.senna@gmail.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