From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Namrata A Shettar <namrataashettar@gmail.com>
Cc: outreachy-kernel <outreachy-kernel@googlegroups.com>,
Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hsweeten@visionengravers.com>,
Leslie Klein <lesliebklein@gmail.com>
Subject: Re: [PATCH] staging: comedi: Optimize code using logical short-circuiting
Date: Sat, 17 Sep 2016 20:35:22 +0200 [thread overview]
Message-ID: <20160917183522.GA30404@kroah.com> (raw)
In-Reply-To: <20160916192454.GA6366@namrata-HP-Pavilion-g6-Notebook-PC>
On Sat, Sep 17, 2016 at 12:54:59AM +0530, Namrata A Shettar wrote:
> Optimize code using logical short-circuiting. Two if statements
> having same return value is equivalent to a single if statement with
> condition being the union of the prior two.
>
> Signed-off-by: Namrata A Shettar <namrataashettar@gmail.com>
> ---
> drivers/staging/comedi/comedi_fops.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
> index 1999eed..0d69ed7 100644
> --- a/drivers/staging/comedi/comedi_fops.c
> +++ b/drivers/staging/comedi/comedi_fops.c
> @@ -791,9 +791,7 @@ static int is_device_busy(struct comedi_device *dev)
>
> for (i = 0; i < dev->n_subdevices; i++) {
> s = &dev->subdevices[i];
> - if (s->busy)
> - return 1;
> - if (s->async && comedi_buf_is_mmapped(s))
> + if (s->busy || (s->async && comedi_buf_is_mmapped(s)))
> return 1;
The original code was easier to read.
We write kernel code for developers first, and the compiler second. In
either case, the compiler will create the same output, you haven't
really saved any logic or speed here. You have made it harder to read
and follow, so I will have to reject this change, sorry.
thanks,
greg k-h
next prev parent reply other threads:[~2016-09-17 18:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 19:24 [PATCH] staging: comedi: Optimize code using logical short-circuiting Namrata A Shettar
2016-09-17 18:35 ` Greg Kroah-Hartman [this message]
2016-09-18 4:44 ` Namrata A Shettar
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=20160917183522.GA30404@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=abbotti@mev.co.uk \
--cc=hsweeten@visionengravers.com \
--cc=lesliebklein@gmail.com \
--cc=namrataashettar@gmail.com \
--cc=outreachy-kernel@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.