From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754830AbdJIVG5 (ORCPT ); Mon, 9 Oct 2017 17:06:57 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:45072 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754098AbdJIVGz (ORCPT ); Mon, 9 Oct 2017 17:06:55 -0400 X-Google-Smtp-Source: AOwi7QBA2WmKWUh/JDs2ppP7FgPZQfs7dojVDKKaSPpzEyvViOwIzDeGTagq5MyhchYwv/g/x7dgOQ== Date: Mon, 9 Oct 2017 22:06:53 +0100 From: Christos Gkekas To: Dmitry Torokhov Cc: Nick Dyer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: atmel_mxt_ts - Remove unnecessary byte_offset check Message-ID: <20171009210653.GB2839@inspiron> References: <1507488258-22409-1-git-send-email-chris.gekas@gmail.com> <20171008194116.GB29090@lava.h.shmanahar.org> <20171009173855.GA19253@dtor-ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171009173855.GA19253@dtor-ws> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/17 10:38:55 -0700, Dmitry Torokhov wrote: > On Sun, Oct 08, 2017 at 08:41:16PM +0100, Nick Dyer wrote: > > On Sun, Oct 08, 2017 at 07:44:18PM +0100, Christos Gkekas wrote: > > > Variable byte_offset is unsigned so checking whether it is greater or > > > equal to zero is redundant. > > > > > > Signed-off-by: Christos Gkekas > > > > Yep - looks sensible to me. > > > > Signed-off-by: Nick Dyer > > I believe this has been discussed before and Linus told us to keep the > such checks as is: they neatly document the ranges of values, safe in > case we ever change the type of the variables, and do not cost us > anything at execution time. > Fair enough, thanks for your feedback. I believe you are referring to this: https://lkml.org/lkml/2006/11/28/206 Regards, Christos > > > > > > --- > > > drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > > > index 7659bc4..baafaed 100644 > > > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > > > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > > > @@ -1356,7 +1356,7 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data, > > > > > > byte_offset = reg + i - cfg_start_ofs; > > > > > > - if (byte_offset >= 0 && byte_offset < config_mem_size) { > > > + if (byte_offset < config_mem_size) { > > > *(config_mem + byte_offset) = val; > > > } else { > > > dev_err(dev, "Bad object: reg:%d, T%d, ofs=%d\n", > > > -- > > > 2.7.4 > > > > > Thanks. > > -- > Dmitry