Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1282269 > unrolled thread

Re: [PATCH v4 06/10] thermal: rockchip: consistently use int for temperatures

Started byBrian Norris <computersforpeace@gmail.com>
First post2015-12-02 19:50 +0100
Last post2015-12-03 02:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 06/10] thermal: rockchip: consistently use int for  temperatures Brian Norris <computersforpeace@gmail.com> - 2015-12-02 19:50 +0100
    Re: [PATCH v4 06/10] thermal: rockchip: consistently use int for  temperatures Brian Norris <computersforpeace@gmail.com> - 2015-12-03 01:50 +0100
      Re: [PATCH v4 06/10] thermal: rockchip: consistently use int for  temperatures Caesar Wang <wxt@rock-chips.com> - 2015-12-03 02:20 +0100

#1282269 — Re: [PATCH v4 06/10] thermal: rockchip: consistently use int for temperatures

FromBrian Norris <computersforpeace@gmail.com>
Date2015-12-02 19:50 +0100
SubjectRe: [PATCH v4 06/10] thermal: rockchip: consistently use int for temperatures
Message-ID<qBkDw-2x9-21@gated-at.bofh.it>
Hi Caesar,

On Mon, Nov 09, 2015 at 12:48:58PM +0800, Caesar Wang wrote:
> As Temperature is currently represented as int not long in the thermal
> framework since use int intead of unsigned long/long to represent
> temperature to avoid bogus overheat detection when negative temperature
> reported.
> 
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> 
> ---
> 
> Changes in v4:
> - fix the warning from the print message.
> 
> Changes in v3:
> - As the Patch v2 comments, Add a new patch to fix it.
> 
> Changes in v2: None
> Changes in v1: None
> 
>  drivers/thermal/rockchip_thermal.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> index 7c5b784..73d47f8 100644
> --- a/drivers/thermal/rockchip_thermal.c
> +++ b/drivers/thermal/rockchip_thermal.c
> @@ -88,7 +88,7 @@ struct rockchip_tsadc_chip {
>  	int chn_num;
>  
>  	/* The hardware-controlled tshut property */
> -	long tshut_temp;
> +	int tshut_temp;
>  	enum tshut_mode tshut_mode;
>  	enum tshut_polarity tshut_polarity;
>  

...

> @@ -126,7 +126,7 @@ struct rockchip_thermal_data {
>  
>  	void __iomem *regs;
>  
> -	long tshut_temp;
> +	int tshut_temp;

FYI, this change is triggering a new warning in Coverity, below:

>  	enum tshut_mode tshut_mode;
>  	enum tshut_polarity tshut_polarity;
>  };

...

> @@ -477,7 +477,7 @@ static int rockchip_configure_from_dt(struct device *dev,
>  	}
>  
>  	if (thermal->tshut_temp > INT_MAX) {

     CID 1341498:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
     "thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.

I don't think this condition is even useful any more, so maybe we should
just kill the 'if' block.

> -		dev_err(dev, "Invalid tshut temperature specified: %ld\n",
> +		dev_err(dev, "Invalid tshut temperature specified: %d\n",
>  			thermal->tshut_temp);
>  		return -ERANGE;
>  	}

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1282628

FromBrian Norris <computersforpeace@gmail.com>
Date2015-12-03 01:50 +0100
Message-ID<qBqfT-68m-1@gated-at.bofh.it>
In reply to#1282269
Hi Caesar,

On Thu, Dec 03, 2015 at 08:42:38AM +0800, Caesar Wang wrote:
> ? 2015?12?03? 02:38, Brian Norris ??:
> 
> [.....]
> >  	if (thermal->tshut_temp > INT_MAX) {
> >      CID 1341498:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
> >      "thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.
> >
> >I don't think this condition is even useful any more, so maybe we should
> >just kill the 'if' block.
> 
> See the patch to fix
> it.----->(https://patchwork.kernel.org/patch/7720601/)
> <https://patchwork.kernel.org/patch/7720601/>

-	if (thermal->tshut_temp > INT_MAX) {
+	if (!(thermal->tshut_temp < INT_MAX)) {

Huh? That still doesn't make much sense. The condition is still
impossible, since thermal->tshut_temp is an int. You've just made it
slightly harder for static analyzers to notice the impossibility.

> This patch is merged into kernel 4.4-rc3.

No it isn't, and I'm glad. The patch is silly.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1282632

FromCaesar Wang <wxt@rock-chips.com>
Date2015-12-03 02:20 +0100
Message-ID<qBqIW-6yl-3@gated-at.bofh.it>
In reply to#1282628
Hi Brain,

于 2015年12月03日 08:49, Brian Norris 写道:
> Hi Caesar,
>
> On Thu, Dec 03, 2015 at 08:42:38AM +0800, Caesar Wang wrote:
>> ? 2015?12?03? 02:38, Brian Norris ??:
>>
>> [.....]
>>>   	if (thermal->tshut_temp > INT_MAX) {
>>>       CID 1341498:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
>>>       "thermal->tshut_temp > 2147483647 /* (int)(~0U >> 1) */" is always false regardless of the values of its operands. This occurs as the logical operand of if.
>>>
>>> I don't think this condition is even useful any more, so maybe we should
>>> just kill the 'if' block.
>> See the patch to fix
>> it.----->(https://patchwork.kernel.org/patch/7720601/)
>> <https://patchwork.kernel.org/patch/7720601/>
> -	if (thermal->tshut_temp > INT_MAX) {
> +	if (!(thermal->tshut_temp < INT_MAX)) {
>
> Huh? That still doesn't make much sense. The condition is still
> impossible, since thermal->tshut_temp is an int. You've just made it
> slightly harder for static analyzers to notice the impossibility.

Okay, that's possible remove this condition as you said.

- if (thermal->tshut_temp > INT_MAX) {
- dev_err(dev, "Invalid tshut temperature specified: %d\n",
- thermal->tshut_temp);
- return -ERANGE;
- }

Thanks!
>
>> This patch is merged into kernel 4.4-rc3.
> No it isn't, and I'm glad. The patch is silly.
>
> Brian
>
>
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web