Skip to contentSkip to conversation

power: supply: core: fix clang -Wunsequenced

PATCH In review Phong Tran 3 participants 3 messages May 2, 2019 Power supply

lore
Share & tools
lore

Phong Tran

author
#0 lore raw

PATCH 1/1 power: supply: core: fix clang -Wunsequenced

The increment operator of pointer in be32_to_cpu() is not explicitly. It made the warning from clang:

drivers/power/supply/power_supply_core.c:674:36: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced] drivers/power/supply/power_supply_core.c:675:41: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced]

---
 drivers/power/supply/power_supply_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_core.c +4 -2
index c917a8b43b2b..7cc6f5fac0d0 100644
@@ -665,8 +665,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
 		}
 
 		for (i = 0; i < tab_len; i++) {
-			table[i].ocv = be32_to_cpu(*list++);
-			table[i].capacity = be32_to_cpu(*list++);
+			table[i].ocv = be32_to_cpu(*list);
+			list++;
+			table[i].capacity = be32_to_cpu(*list);
+			list++;
 		}
 	}
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Phong Tran

The increment operator of pointer in be32_to_cpu() is not explicitly. It made the warning from clang:

drivers/power/supply/power_supply_core.c:674:36: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced] drivers/power/supply/power_supply_core.c:675:41: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced]

---
 drivers/power/supply/power_supply_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_core.c +0 -0
index c917a8b43b2b..7cc6f5fac0d0 100644

drivers/power/supply/power_supply_core.c int power_supply_get_battery_info(struct power_supply *psy, · line 671

Quoted 9 lines
drivers/power/supply/power_supply_core.c +4 -2
@@ -665,8 +665,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
                }
 
                for (i = 0; i < tab_len; i++) {
-                       table[i].ocv = be32_to_cpu(*list++);
-                       table[i].capacity = be32_to_cpu(*list++);
+                       table[i].ocv = be32_to_cpu(*list);
+                       list++;
+                       table[i].capacity = be32_to_cpu(*list);
+                       list++;

I prefer preincrement/predecrement to postincrement/postdecrement unless absolutely necessary, but it really doesn't matter in this case. Thanks for the patch.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
In reply to Phong Tran

Hi,

Quoted 8 lines · Phong Tran

The increment operator of pointer in be32_to_cpu() is not explicitly. It made the warning from clang:

drivers/power/supply/power_supply_core.c:674:36: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced] drivers/power/supply/power_supply_core.c:675:41: error: multiple unsequenced modifications to 'list' [-Werror,-Wunsequenced]

Quoted 4 lines

---

Thanks, queued to power-supply's for-next branch.

-- Sebastian

Quoted 23 lines
 drivers/power/supply/power_supply_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/power_supply_core.c +4 -2
index c917a8b43b2b..7cc6f5fac0d0 100644
@@ -665,8 +665,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
 		}
 
 		for (i = 0; i < tab_len; i++) {
-			table[i].ocv = be32_to_cpu(*list++);
-			table[i].capacity = be32_to_cpu(*list++);
+			table[i].ocv = be32_to_cpu(*list);
+			list++;
+			table[i].capacity = be32_to_cpu(*list);
+			list++;
 		}
 	}
 
Signature · 1 line
2.21.0