linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
@ 2023-05-13 11:29 Krzysztof Kozlowski
  2023-05-15  3:33 ` Bjorn Andersson
  2023-05-15  9:36 ` Konrad Dybcio
  0 siblings, 2 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-13 11:29 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel
  Cc: Krzysztof Kozlowski

Unsigned int "minor" is always >= 0 as reported by Smatch:

  drivers/soc/qcom/rpmh-rsc.c:1076 rpmh_rsc_probe() warn: always true condition '(drv->ver.minor >= 0) => (0-u32max >= 0)'

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soc/qcom/rpmh-rsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index f93544f6d796..0dd4363ebac8 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -1073,7 +1073,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
 	drv->ver.minor = rsc_id & (MINOR_VER_MASK << MINOR_VER_SHIFT);
 	drv->ver.minor >>= MINOR_VER_SHIFT;
 
-	if (drv->ver.major == 3 && drv->ver.minor >= 0)
+	if (drv->ver.major == 3)
 		drv->regs = rpmh_rsc_reg_offset_ver_3_0;
 	else
 		drv->regs = rpmh_rsc_reg_offset_ver_2_7;
-- 
2.34.1


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

* Re: [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
  2023-05-13 11:29 [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision Krzysztof Kozlowski
@ 2023-05-15  3:33 ` Bjorn Andersson
  2023-05-15  9:36 ` Konrad Dybcio
  1 sibling, 0 replies; 5+ messages in thread
From: Bjorn Andersson @ 2023-05-15  3:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski, linux-kernel, linux-arm-msm, Andy Gross,
	Konrad Dybcio

On Sat, 13 May 2023 13:29:13 +0200, Krzysztof Kozlowski wrote:
> Unsigned int "minor" is always >= 0 as reported by Smatch:
> 
>   drivers/soc/qcom/rpmh-rsc.c:1076 rpmh_rsc_probe() warn: always true condition '(drv->ver.minor >= 0) => (0-u32max >= 0)'
> 
> 

Applied, thanks!

[1/1] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
      commit: 3395d36e6805786c26d13188735bc796b9d7a7c9

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

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

* Re: [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
  2023-05-13 11:29 [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision Krzysztof Kozlowski
  2023-05-15  3:33 ` Bjorn Andersson
@ 2023-05-15  9:36 ` Konrad Dybcio
  2023-05-15 10:03   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 5+ messages in thread
From: Konrad Dybcio @ 2023-05-15  9:36 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Andy Gross, Bjorn Andersson, linux-arm-msm,
	linux-kernel



On 13.05.2023 13:29, Krzysztof Kozlowski wrote:
> Unsigned int "minor" is always >= 0 as reported by Smatch:
> 
>   drivers/soc/qcom/rpmh-rsc.c:1076 rpmh_rsc_probe() warn: always true condition '(drv->ver.minor >= 0) => (0-u32max >= 0)'
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
I can see how it made sense from a human POV, but then it still
does with the right hand side removed..

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  drivers/soc/qcom/rpmh-rsc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
> index f93544f6d796..0dd4363ebac8 100644
> --- a/drivers/soc/qcom/rpmh-rsc.c
> +++ b/drivers/soc/qcom/rpmh-rsc.c
> @@ -1073,7 +1073,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)
>  	drv->ver.minor = rsc_id & (MINOR_VER_MASK << MINOR_VER_SHIFT);
>  	drv->ver.minor >>= MINOR_VER_SHIFT;
>  
> -	if (drv->ver.major == 3 && drv->ver.minor >= 0)
> +	if (drv->ver.major == 3)
>  		drv->regs = rpmh_rsc_reg_offset_ver_3_0;
>  	else
>  		drv->regs = rpmh_rsc_reg_offset_ver_2_7;

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

* Re: [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
  2023-05-15  9:36 ` Konrad Dybcio
@ 2023-05-15 10:03   ` Krzysztof Kozlowski
  2023-05-15 10:04     ` Konrad Dybcio
  0 siblings, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-15 10:03 UTC (permalink / raw)
  To: Konrad Dybcio, Andy Gross, Bjorn Andersson, linux-arm-msm, linux-kernel

On 15/05/2023 11:36, Konrad Dybcio wrote:
> 
> 
> On 13.05.2023 13:29, Krzysztof Kozlowski wrote:
>> Unsigned int "minor" is always >= 0 as reported by Smatch:
>>
>>   drivers/soc/qcom/rpmh-rsc.c:1076 rpmh_rsc_probe() warn: always true condition '(drv->ver.minor >= 0) => (0-u32max >= 0)'
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
> I can see how it made sense from a human POV, but then it still
> does with the right hand side removed..

I would argue that for human it does not make sense. Why checking minor
for >=0? Even if minor ver could be negative (error case?), what would
that mean in that context? major ver == 3 but minor == ERRNO, so we will
have drv->regs == 2.7?

Best regards,
Krzysztof


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

* Re: [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision
  2023-05-15 10:03   ` Krzysztof Kozlowski
@ 2023-05-15 10:04     ` Konrad Dybcio
  0 siblings, 0 replies; 5+ messages in thread
From: Konrad Dybcio @ 2023-05-15 10:04 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Andy Gross, Bjorn Andersson, linux-arm-msm,
	linux-kernel



On 15.05.2023 12:03, Krzysztof Kozlowski wrote:
> On 15/05/2023 11:36, Konrad Dybcio wrote:
>>
>>
>> On 13.05.2023 13:29, Krzysztof Kozlowski wrote:
>>> Unsigned int "minor" is always >= 0 as reported by Smatch:
>>>
>>>   drivers/soc/qcom/rpmh-rsc.c:1076 rpmh_rsc_probe() warn: always true condition '(drv->ver.minor >= 0) => (0-u32max >= 0)'
>>>
>>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>> ---
>> I can see how it made sense from a human POV, but then it still
>> does with the right hand side removed..
> 
> I would argue that for human it does not make sense. Why checking minor
> for >=0? Even if minor ver could be negative (error case?), what would
> that mean in that context? major ver == 3 but minor == ERRNO, so we will
> have drv->regs == 2.7?
I'd say that's just a direct natural-to-computer-language translation of
"above version 3.0", but yeah it does not really make sense to check
for negative versions..

Konrad
> 
> Best regards,
> Krzysztof
> 

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

end of thread, other threads:[~2023-05-15 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-13 11:29 [PATCH] soc: qcom: rpmh-rsc: drop redundant unsigned >=0 comparision Krzysztof Kozlowski
2023-05-15  3:33 ` Bjorn Andersson
2023-05-15  9:36 ` Konrad Dybcio
2023-05-15 10:03   ` Krzysztof Kozlowski
2023-05-15 10:04     ` Konrad Dybcio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).