2019-05-02 01:29:52

by Phong Tran

[permalink] [raw]
Subject: [PATCH] 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]

Link: https://github.com/ClangBuiltLinux/linux/issues/460

Signed-off-by: Phong Tran <[email protected]>
---
drivers/power/supply/power_supply_core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index c917a8b43b2b..7cc6f5fac0d0 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -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++;
}
}

--
2.21.0


2019-05-02 18:02:39

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH] power: supply: core: fix clang -Wunsequenced

On Wed, May 1, 2019 at 6:28 PM Phong Tran <[email protected]> wrote:
>
> 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]
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/460
>
> Signed-off-by: Phong Tran <[email protected]>
> ---
> drivers/power/supply/power_supply_core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index c917a8b43b2b..7cc6f5fac0d0 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -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.
Reviewed-by: Nick Desaulniers <[email protected]>

--
Thanks,
~Nick Desaulniers

2019-05-02 20:17:28

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] power: supply: core: fix clang -Wunsequenced

Hi,

On Thu, May 02, 2019 at 08:27:06AM +0700, Phong Tran wrote:
> 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]
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/460
>
> Signed-off-by: Phong Tran <[email protected]>
> ---

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

-- Sebastian

> drivers/power/supply/power_supply_core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index c917a8b43b2b..7cc6f5fac0d0 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -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++;
> }
> }
>
> --
> 2.21.0
>


Attachments:
(No filename) (1.35 kB)
signature.asc (849.00 B)
Download all attachments