Skip to contentSkip to conversation

HID: core: remove unneeded assignment in hid_process_report()

PATCH Applied Lukas Bulwahn 3 participants 3 messages Jul 1, 2022 – Jul 21, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: core: remove unneeded assignment in hid_process_report()

Commit bebcc522fbee ("HID: core: for input reports, process the usages by priority list") split the iteration into two distinct loops in hid_process_report().

After this change, the variable field is only used while iterating in the second loop and the assignment of values to this variable in the first loop is simply not needed.

Remove the unneeded assignment during retrieval. No functional change and no change in the resulting object code.

This was discovered as a dead store with clang-analyzer.

---
Benjamin, Jiri, please pick this minor non-urgent clean-up patch.

 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-core.c +1 -1
index 00154a1cd2d8..b7f5566e338d 100644
@@ -1662,7 +1662,7 @@ static void hid_process_report(struct hid_device *hid,
 
 	/* first retrieve all incoming values in data */
 	for (a = 0; a < report->maxfield; a++)
-		hid_input_fetch_field(hid, field = report->field[a], data);
+		hid_input_fetch_field(hid, report->field[a], data);
 
 	if (!list_empty(&report->field_entry_list)) {
 		/* INPUT_REPORT, we have a priority list of fields */
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Lukas Bulwahn

Commit bebcc522fbee ("HID: core: for input reports, process the usages by priority list") split the iteration into two distinct loops in hid_process_report().

After this change, the variable field is only used while iterating in the second loop and the assignment of values to this variable in the first loop is simply not needed.

Remove the unneeded assignment during retrieval. No functional change and no change in the resulting object code.

This was discovered as a dead store with clang-analyzer.

---
Benjamin, Jiri, please pick this minor non-urgent clean-up patch.

  drivers/hid/hid-core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-core.c +0 -0
index 00154a1cd2d8..b7f5566e338d 100644

drivers/hid/hid-core.c static void hid_process_report(struct hid_device *hid, · line 1668

Quoted 8 lines
drivers/hid/hid-core.c +1 -1
@@ -1662,7 +1662,7 @@ static void hid_process_report(struct hid_device *hid,
 
  	/* first retrieve all incoming values in data */
  	for (a = 0; a < report->maxfield; a++)
-		hid_input_fetch_field(hid, field = report->field[a], data);
+		hid_input_fetch_field(hid, report->field[a], data);
 
  	if (!list_empty(&report->field_entry_list)) {
  		/* INPUT_REPORT, we have a priority list of fields */
maintainer Applied
#2 lore raw
In reply to Lukas Bulwahn
Quoted 25 lines · Lukas Bulwahn

Commit bebcc522fbee ("HID: core: for input reports, process the usages by priority list") split the iteration into two distinct loops in hid_process_report().

After this change, the variable field is only used while iterating in the second loop and the assignment of values to this variable in the first loop is simply not needed.

Remove the unneeded assignment during retrieval. No functional change and no change in the resulting object code.

This was discovered as a dead store with clang-analyzer.

---
Benjamin, Jiri, please pick this minor non-urgent clean-up patch.

 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-core.c +0 -0
index 00154a1cd2d8..b7f5566e338d 100644

drivers/hid/hid-core.c static void hid_process_report(struct hid_device *hid, · line 1667

Quoted 7 lines
drivers/hid/hid-core.c +1 -1
@@ -1662,7 +1662,7 @@ static void hid_process_report(struct hid_device *hid,
 
 	/* first retrieve all incoming values in data */
 	for (a = 0; a < report->maxfield; a++)
-		hid_input_fetch_field(hid, field = report->field[a], data);
+		hid_input_fetch_field(hid, report->field[a], data);
 
 	if (!list_empty(&report->field_entry_list)) {

Applied, thanks Lukas.

Signature · 2 lines
Jiri Kosina
SUSE Labs