Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752089AbdGBWEg (ORCPT ); Sun, 2 Jul 2017 18:04:36 -0400 Received: from smtprelay0233.hostedemail.com ([216.40.44.233]:41427 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751894AbdGBWEd (ORCPT ); Sun, 2 Jul 2017 18:04:33 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:3872:3874:4321:5007:8526:10004:10400:10848:11026:11232:11658:11914:12043:12048:12296:12438:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21611:21627:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: prose89_a4fa6fae1d2e X-Filterd-Recvd-Size: 1682 Message-ID: <1499033068.9885.7.camel@perches.com> Subject: Re: [PATCH] HID: wacom: Remove comparison of u8 mode with zero and simplify. From: Joe Perches To: Christos Gkekas , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 02 Jul 2017 15:04:28 -0700 In-Reply-To: <1499032463-22425-1-git-send-email-chris.gekas@gmail.com> References: <1499032463-22425-1-git-send-email-chris.gekas@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 785 Lines: 20 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.