* [PATCH -next] hwmon: (nct6683) remove unused variable in nct6683_create_attr_group
@ 2022-09-27 11:43 Zeng Heng
2022-10-02 15:01 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Zeng Heng @ 2022-09-27 11:43 UTC (permalink / raw)
To: jdelvare, linux; +Cc: linux-hwmon, liwei391, zengheng4
When enable 'unused-but-set-variable' compile
warning option, it would raise warning as below:
drivers/hwmon/nct6683.c:415:9:
warning: variable 'j' set but not used [-Wunused-but-set-variable]
Variable 'j' in nct6683_create_attr_group is unused,
so remove it and simplify the 'for' loop.
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
drivers/hwmon/nct6683.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 6a9f420e7d32..a872f783e9cc 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -412,7 +412,7 @@ nct6683_create_attr_group(struct device *dev,
struct sensor_device_attr_u *su;
struct attribute_group *group;
struct attribute **attrs;
- int i, j, count;
+ int i, count;
if (repeat <= 0)
return ERR_PTR(-EINVAL);
@@ -443,7 +443,7 @@ nct6683_create_attr_group(struct device *dev,
for (i = 0; i < repeat; i++) {
t = tg->templates;
- for (j = 0; *t != NULL; j++) {
+ while (*t) {
snprintf(su->name, sizeof(su->name),
(*t)->dev_attr.attr.name, tg->base + i);
if ((*t)->s2) {
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] hwmon: (nct6683) remove unused variable in nct6683_create_attr_group
2022-09-27 11:43 [PATCH -next] hwmon: (nct6683) remove unused variable in nct6683_create_attr_group Zeng Heng
@ 2022-10-02 15:01 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-10-02 15:01 UTC (permalink / raw)
To: Zeng Heng; +Cc: jdelvare, linux-hwmon, liwei391
On Tue, Sep 27, 2022 at 07:43:52PM +0800, Zeng Heng wrote:
> When enable 'unused-but-set-variable' compile
> warning option, it would raise warning as below:
>
> drivers/hwmon/nct6683.c:415:9:
> warning: variable 'j' set but not used [-Wunused-but-set-variable]
>
> Variable 'j' in nct6683_create_attr_group is unused,
> so remove it and simplify the 'for' loop.
>
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/nct6683.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
> index 6a9f420e7d32..a872f783e9cc 100644
> --- a/drivers/hwmon/nct6683.c
> +++ b/drivers/hwmon/nct6683.c
> @@ -412,7 +412,7 @@ nct6683_create_attr_group(struct device *dev,
> struct sensor_device_attr_u *su;
> struct attribute_group *group;
> struct attribute **attrs;
> - int i, j, count;
> + int i, count;
>
> if (repeat <= 0)
> return ERR_PTR(-EINVAL);
> @@ -443,7 +443,7 @@ nct6683_create_attr_group(struct device *dev,
>
> for (i = 0; i < repeat; i++) {
> t = tg->templates;
> - for (j = 0; *t != NULL; j++) {
> + while (*t) {
> snprintf(su->name, sizeof(su->name),
> (*t)->dev_attr.attr.name, tg->base + i);
> if ((*t)->s2) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-02 15:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-27 11:43 [PATCH -next] hwmon: (nct6683) remove unused variable in nct6683_create_attr_group Zeng Heng
2022-10-02 15:01 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox