All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Christos Gkekas <chris.gekas@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify.
Date: Sun, 02 Jul 2017 15:04:28 -0700	[thread overview]
Message-ID: <1499033068.9885.7.camel@perches.com> (raw)
In-Reply-To: <1499032463-22425-1-git-send-email-chris.gekas@gmail.com>

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.


  reply	other threads:[~2017-07-02 22:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-02 21:54 [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify Christos Gkekas
2017-07-02 22:04 ` Joe Perches [this message]
2017-07-02 22:32   ` Christos Gkekas
  -- strict thread matches above, loose matches on Subject: below --
2017-07-02 22:46 Christos Gkekas

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=1499033068.9885.7.camel@perches.com \
    --to=joe@perches.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=chris.gekas@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --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 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.