Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1679572
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify. |
| Date | 2017-07-03 00:10 +0200 |
| Message-ID | <tYVe2-8rT-9@gated-at.bofh.it> (permalink) |
| References | <tYV4l-88R-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, 2017-07-02 at 22:54 +0100, Christos Gkekas wrote: > Variable mode in method wacom_show_remote_mode() is defined as u8, thus > statement (mode >= 0) is always true and should be removed, simplifying > the logic. [] > diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c [] > @@ -1671,10 +1671,7 @@ static ssize_t wacom_show_remote_mode(struct kobject *kobj, > u8 mode; > > mode = wacom->led.groups[index].select; > - if (mode >= 0 && mode < 3) > - return snprintf(buf, PAGE_SIZE, "%d\n", mode); > - else > - return snprintf(buf, PAGE_SIZE, "%d\n", -1); > + return snprintf(buf, PAGE_SIZE, "%d\n", mode < 3 ? mode : -1); It's also hard to imagine that PAGE_SIZE could be less than 4 bytes so return sprintf(buf, "%d\n", mode < 3 ? mode : -1); could work too.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify. Christos Gkekas <chris.gekas@gmail.com> - 2017-07-03 00:00 +0200
Re: [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify. Joe Perches <joe@perches.com> - 2017-07-03 00:10 +0200
Re: [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify. Christos Gkekas <chris.gekas@gmail.com> - 2017-07-03 00:40 +0200
csiph-web