From: Willy Tarreau <w@1wt.eu>
To: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] Staging: panel: Make statement more readable
Date: Sat, 2 Jan 2016 07:53:12 +0100 [thread overview]
Message-ID: <20160102065312.GA16028@1wt.eu> (raw)
In-Reply-To: <fd59698e82257893f9056feed189a8fbe483e2f7.1451418912.git.ksenija.stanojevic@gmail.com>
Hi Ksenija,
several points, see below.
On Tue, Dec 29, 2015 at 09:11:03PM +0100, Ksenija Stanojevic wrote:
> Broke statement into 3 different lines to make it more readable.
>
> Signeded-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
^^
Extra "ed". Don't waste your time typing it by hand, several git commands
(including git-commit and git-format-patch) will do it for you when you
pass "-s".
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index 70cb9f3..207d8d5 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -2054,8 +2054,8 @@ static u8 input_name2mask(const char *name, __u64 *mask, __u64 *value,
> while (*name) {
> int in, out, bit, neg;
>
> - for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name);
> - in++)
> + for (in = 0;
> + (in < sizeof(sigtab)) && (sigtab[in] != *name); in++)
> ;
>
> if (in >= sizeof(sigtab))
well, this one is still ugly in my opinion. I've just looked at the code
and it was crap originally :
- sigtab[] is declared as static and without a trailing zero
- the for loop uses extra parenthesis and basically only reimplements
strchr()
- the end condition is tested again after the for loop
=> I'd rather use strchr(), and clean up this part, approx like this, but
do it as you want :
- static char sigtab[10] = "EeSsPpAaBb";
+ const char sigtab[] = "EeSsPpAaBb";
...
while (*name) {
int in, out, bit, neg;
+ const char *idx;
- for (in = 0; (in < sizeof(sigtab)) && (sigtab[in] != *name);
- in++)
-
- if (in >= sizeof(sigtab))
- return 0;
+ idx = strchr(sigtab, *name);
+ if (!idx)
+ return 0;
+
+ in = idx - sigtab;
I think it's more readable this way.
Regards,
Willy
prev parent reply other threads:[~2016-01-02 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 20:04 [PATCH 0/5] Staging: panel: TODO fixes Ksenija Stanojevic
2015-12-29 20:05 ` [PATCH 1/5] Staging: panel: Use u8 type Ksenija Stanojevic
2015-12-29 20:07 ` [PATCH 2/5] Staging: panel: Remove typedef pmask_t Ksenija Stanojevic
2015-12-29 20:08 ` [PATCH 3/5] Staging: panel: Remove ULL Ksenija Stanojevic
2015-12-29 20:59 ` Ilia Mirkin
2015-12-29 23:35 ` Willy Tarreau
2015-12-29 20:09 ` [PATCH 4/5] Staging: panel: Reduce value range for *name Ksenija Stanojevic
2015-12-29 20:11 ` [PATCH 5/5] Staging: panel: Make statement more readable Ksenija Stanojevic
2016-01-02 6:53 ` Willy Tarreau [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=20160102065312.GA16028@1wt.eu \
--to=w@1wt.eu \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=ksenija.stanojevic@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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).