Skip to contentSkip to conversation

Input: atmel_mxt_ts - remove unneeded check

PATCH In review Dmitry Torokhov 1 participant 2 messages Aug 17, 2014 – Aug 19, 2014

Subsystems (3)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: atmel_mxt_ts - remove unneeded check

This fixes the following issue reported by Coverity:

** CID 1231785: Unsigned compared against 0 (NO_EFFECT) /drivers/input/touchscreen/atmel_mxt_ts.c: 1157 in mxt_prepare_cfg_mem()

The variable 'byte_offset' is declared as unsigned int and therefore can never be less than 0.

---
 drivers/input/touchscreen/atmel_mxt_ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/atmel_mxt_ts.c +1 -1
index db178ed..8780c9a 100644
@@ -1154,7 +1154,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 · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
author maintainer
#1 lore raw
Quoted 8 lines · Dmitry Torokhov

This fixes the following issue reported by Coverity:

** CID 1231785: Unsigned compared against 0 (NO_EFFECT) /drivers/input/touchscreen/atmel_mxt_ts.c: 1157 in mxt_prepare_cfg_mem()

The variable 'byte_offset' is declared as unsigned int and therefore can never be less than 0.

Withdrawn - Linus recommended to become intimate with the compiler instead.

Quoted 24 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
index db178ed..8780c9a 100644
@@ -1154,7 +1154,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 · 5 lines
2.1.0.rc2.206.gedb03e5


-- 
Dmitry
Signature · 1 line
Dmitry