public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] pwm: lp3943: Fix an incorrect type in lp3943_pwm_parse_dt()
@ 2024-08-09  8:05 Jiapeng Chong
  2024-08-09  8:50 ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Jiapeng Chong @ 2024-08-09  8:05 UTC (permalink / raw)
  To: ukleinek; +Cc: linux-pwm, linux-kernel, Jiapeng Chong, Abaci Robot

The return value from the call to of_property_count_u32_elems() is int.
However, the return value is being assigned to an u32 variable
'num_outputs', so making 'num_outputs' an int.

./drivers/pwm/pwm-lp3943.c:238:6-17: WARNING: Unsigned expression compared with zero: num_outputs <= 0.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9710
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/pwm/pwm-lp3943.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
index f0e94c9e5956..90b0733c00c1 100644
--- a/drivers/pwm/pwm-lp3943.c
+++ b/drivers/pwm/pwm-lp3943.c
@@ -218,8 +218,7 @@ static int lp3943_pwm_parse_dt(struct device *dev,
 	struct lp3943_platform_data *pdata;
 	struct lp3943_pwm_map *pwm_map;
 	enum lp3943_pwm_output *output;
-	int i, err, count = 0;
-	u32 num_outputs;
+	int i, err, num_outputs, count = 0;
 
 	if (!node)
 		return -EINVAL;
-- 
2.32.0.3.g01195cf9f


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] pwm: lp3943: Fix an incorrect type in lp3943_pwm_parse_dt()
  2024-08-09  8:05 [PATCH -next] pwm: lp3943: Fix an incorrect type in lp3943_pwm_parse_dt() Jiapeng Chong
@ 2024-08-09  8:50 ` Uwe Kleine-König
  2024-08-10 17:03   ` Uwe Kleine-König
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2024-08-09  8:50 UTC (permalink / raw)
  To: Jiapeng Chong, Rob Herring (Arm); +Cc: linux-pwm, linux-kernel, Abaci Robot

Hello Jiapeng,

On 8/9/24 10:05, Jiapeng Chong wrote:
> The return value from the call to of_property_count_u32_elems() is int.
> However, the return value is being assigned to an u32 variable
> 'num_outputs', so making 'num_outputs' an int.
> 
> ./drivers/pwm/pwm-lp3943.c:238:6-17: WARNING: Unsigned expression compared with zero: num_outputs <= 0.

Which tool does emit this warning? My test build (with C=1 and W=1) 
doesn't emit it.

> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9710
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

This problem was introduced in a commit in next:

Fixes: d6a56f3bb650 ("pwm: lp3943: Use of_property_count_u32_elems() to 
get property length")

Rob: I guess this wasn't the only conversion of this type. Maybe these 
others suffer from the same problem?!

> ---
>   drivers/pwm/pwm-lp3943.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
> index f0e94c9e5956..90b0733c00c1 100644
> --- a/drivers/pwm/pwm-lp3943.c
> +++ b/drivers/pwm/pwm-lp3943.c
> @@ -218,8 +218,7 @@ static int lp3943_pwm_parse_dt(struct device *dev,
>   	struct lp3943_platform_data *pdata;
>   	struct lp3943_pwm_map *pwm_map;
>   	enum lp3943_pwm_output *output;
> -	int i, err, count = 0;
> -	u32 num_outputs;
> +	int i, err, num_outputs, count = 0;
>   
>   	if (!node)
>   		return -EINVAL;

Nitpick (maybe even a subjective one):
While touching num_outputs, its scope could be reduced to the for loop.

Best regards
Uwe

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] pwm: lp3943: Fix an incorrect type in lp3943_pwm_parse_dt()
  2024-08-09  8:50 ` Uwe Kleine-König
@ 2024-08-10 17:03   ` Uwe Kleine-König
  0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2024-08-10 17:03 UTC (permalink / raw)
  To: Jiapeng Chong, Rob Herring (Arm); +Cc: linux-pwm, linux-kernel, Abaci Robot

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

Hello,

On Fri, Aug 09, 2024 at 10:50:49AM +0200, Uwe Kleine-König wrote:
> On 8/9/24 10:05, Jiapeng Chong wrote:
> > The return value from the call to of_property_count_u32_elems() is int.
> > However, the return value is being assigned to an u32 variable
> > 'num_outputs', so making 'num_outputs' an int.
> > 
> > ./drivers/pwm/pwm-lp3943.c:238:6-17: WARNING: Unsigned expression compared with zero: num_outputs <= 0.
> 
> Which tool does emit this warning? My test build (with C=1 and W=1) doesn't
> emit it.
> 
> > Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> > Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9710
> > Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> 
> This problem was introduced in a commit in next:
> 
> Fixes: d6a56f3bb650 ("pwm: lp3943: Use of_property_count_u32_elems() to get
> property length")
> 
> Rob: I guess this wasn't the only conversion of this type. Maybe these
> others suffer from the same problem?!

I hoped for some more feedback, but anyhow: Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next

with the Fixes line.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-10 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09  8:05 [PATCH -next] pwm: lp3943: Fix an incorrect type in lp3943_pwm_parse_dt() Jiapeng Chong
2024-08-09  8:50 ` Uwe Kleine-König
2024-08-10 17:03   ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox