Input: atmel_mxt_ts - Remove unnecessary byte_offset check
Subsystems (3)
PATCH 1/1 Input: atmel_mxt_ts - Remove unnecessary byte_offset check
Variable byte_offset is unsigned so checking whether it is greater or equal to zero is redundant.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/atmel_mxt_ts.c +1 -1
@@ -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",
Signature · 1 line
2.7.4
Nick Dyer
maintainerQuoted 4 lines · Christos Gkekas
Variable
byte_offsetis unsigned so checking whether it is greater or equal to zero is redundant.Signed-off-by Christos Gkekas <[email protected]>
Yep - looks sensible to me.
Quoted 20 lines
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/touchscreen/atmel_mxt_ts.c +1
-1@@ -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",Signature · 1 line
2.7.4
Dmitry Torokhov
maintainerQuoted 9 lines · Nick Dyer
Quoted 4 lines · Christos Gkekas
Variable
byte_offsetis unsigned so checking whether it is greater or equal to zero is redundant.Signed-off-by Christos Gkekas <[email protected]>Yep - looks sensible to me.
Signed-off-by Nick Dyer <[email protected]>
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.
Quoted 13 lines
Quoted 13 lines
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/touchscreen/atmel_mxt_ts.c +0
-0@@ -1356,7 +1356,7 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data, byte_offset = reg + i - cfg_start_ofs;
Quoted 8 lines
Quoted 8 lines
drivers/input/touchscreen/atmel_mxt_ts.c +1
-1-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",Signature · 1 line
2.7.4
Thanks.
Signature · 1 line
Dmitry
Quoted 7 lines · Dmitry Torokhov
Quoted 6 lines · Nick Dyer
Quoted 4 lines · Christos Gkekas
Variable
byte_offsetis unsigned so checking whether it is greater or equal to zero is redundant.Signed-off-by Christos Gkekas <[email protected]>
Quoted 9 lines
Quoted 3 lines
Yep - looks sensible to me.
Signed-off-by Nick Dyer <[email protected]>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
Quoted 27 lines
Quoted 14 lines
Quoted 14 lines
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/touchscreen/atmel_mxt_ts.c +0
-0@@ -1356,7 +1356,7 @@ static int mxt_prepare_cfg_mem(struct mxt_data *data, byte_offset = reg + i - cfg_start_ofs;Quoted 8 lines
Quoted 8 lines
drivers/input/touchscreen/atmel_mxt_ts.c +1
-1-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",Signature · 1 line
2.7.4Thanks.
Signature · 1 line
Dmitry