From: Brian Norris <computersforpeace@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Caesar Wang <wxt@rock-chips.com>,
Eduardo Valentin <edubezval@gmail.com>,
huangtao@rock-chips.com, Heiko Stuebner <heiko@sntech.de>,
dianders@chromium.org, linux-rockchip@lists.infradead.org,
Dan Carpenter <dan.carpenter@oracle.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhang Rui <rui.zhang@intel.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 2/5] thermal: rockchip: fix a impossible condition caused by the warning
Date: Thu, 3 Dec 2015 12:33:57 -0800 [thread overview]
Message-ID: <20151203203357.GA141945@google.com> (raw)
In-Reply-To: <20151203201908.GA34901@dtor-ws>
On Thu, Dec 03, 2015 at 12:19:08PM -0800, Dmitry Torokhov wrote:
> On Thu, Dec 03, 2015 at 04:48:40PM +0800, Caesar Wang wrote:
> > As the Dan report the smatch check the thermal driver warning:
> > drivers/thermal/rockchip_thermal.c:551 rockchip_configure_from_dt()
> > warn: impossible condition '(thermal->tshut_temp > ((~0 >> 1))) =>
> > (s32min-s32max > s32max)'
> >
> > Let's we remove the imposssible condition Since the Temperature is
> > currently represented as int not long in the thermal driver.
> >
> > Fixes: commit 437df2172e8d
> > ("thermal: rockchip: consistently use int for temperatures")
> >
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> >
> > ---
> >
> > Changes in v3:
> > - As Brian comments on https://patchwork.kernel.org/patch/7580661/,
> > let's remove the impossible condition.
> >
> > Changes in v2: None
> > Changes in v1: None
> >
> > drivers/thermal/rockchip_thermal.c | 6 ------
> > 1 file changed, 6 deletions(-)
> >
> > diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> > index ae796ec..611de00 100644
> > --- a/drivers/thermal/rockchip_thermal.c
> > +++ b/drivers/thermal/rockchip_thermal.c
> > @@ -549,12 +549,6 @@ static int rockchip_configure_from_dt(struct device *dev,
> > thermal->tshut_temp = shut_temp;
> > }
> >
> > - if (thermal->tshut_temp > INT_MAX) {
> > - dev_err(dev, "Invalid tshut temperature specified: %d\n",
> > - thermal->tshut_temp);
> > - return -ERANGE;
> > - }
>
> Well, that is not entirely correct. The value that we read from DT is
> u32, but we convert it down to int. I believe you want to move the check
Do we really account for the possibility of sizeof(int) < sizeof(u32)?
EDIT: A bit after writing the above line, I notice my error, but in case
anyone else is thinking the same thing... I guess you're referring to
the sign bit, since we're casting unsigned to signed.
Brian
> up so that you do:
>
> } else if (tshut_temp > INT_MAX) {
> dev_err(dev, "Invalid tshut temperature specified: %d\n",
> thermal->tshut_temp);
> return -ERANGE;
> } else {
> thermal->tshut_temp = shut_temp;
> }
>
> Thanks.
WARNING: multiple messages have this Message-ID (diff)
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 2/5] thermal: rockchip: fix a impossible condition caused by the warning
Date: Thu, 3 Dec 2015 12:33:57 -0800 [thread overview]
Message-ID: <20151203203357.GA141945@google.com> (raw)
In-Reply-To: <20151203201908.GA34901@dtor-ws>
On Thu, Dec 03, 2015 at 12:19:08PM -0800, Dmitry Torokhov wrote:
> On Thu, Dec 03, 2015 at 04:48:40PM +0800, Caesar Wang wrote:
> > As the Dan report the smatch check the thermal driver warning:
> > drivers/thermal/rockchip_thermal.c:551 rockchip_configure_from_dt()
> > warn: impossible condition '(thermal->tshut_temp > ((~0 >> 1))) =>
> > (s32min-s32max > s32max)'
> >
> > Let's we remove the imposssible condition Since the Temperature is
> > currently represented as int not long in the thermal driver.
> >
> > Fixes: commit 437df2172e8d
> > ("thermal: rockchip: consistently use int for temperatures")
> >
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> >
> > ---
> >
> > Changes in v3:
> > - As Brian comments on https://patchwork.kernel.org/patch/7580661/,
> > let's remove the impossible condition.
> >
> > Changes in v2: None
> > Changes in v1: None
> >
> > drivers/thermal/rockchip_thermal.c | 6 ------
> > 1 file changed, 6 deletions(-)
> >
> > diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
> > index ae796ec..611de00 100644
> > --- a/drivers/thermal/rockchip_thermal.c
> > +++ b/drivers/thermal/rockchip_thermal.c
> > @@ -549,12 +549,6 @@ static int rockchip_configure_from_dt(struct device *dev,
> > thermal->tshut_temp = shut_temp;
> > }
> >
> > - if (thermal->tshut_temp > INT_MAX) {
> > - dev_err(dev, "Invalid tshut temperature specified: %d\n",
> > - thermal->tshut_temp);
> > - return -ERANGE;
> > - }
>
> Well, that is not entirely correct. The value that we read from DT is
> u32, but we convert it down to int. I believe you want to move the check
Do we really account for the possibility of sizeof(int) < sizeof(u32)?
EDIT: A bit after writing the above line, I notice my error, but in case
anyone else is thinking the same thing... I guess you're referring to
the sign bit, since we're casting unsigned to signed.
Brian
> up so that you do:
>
> } else if (tshut_temp > INT_MAX) {
> dev_err(dev, "Invalid tshut temperature specified: %d\n",
> thermal->tshut_temp);
> return -ERANGE;
> } else {
> thermal->tshut_temp = shut_temp;
> }
>
> Thanks.
next prev parent reply other threads:[~2015-12-03 20:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 8:48 [PATCH v3 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for thermal driver Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` [PATCH v3 2/5] thermal: rockchip: fix a impossible condition caused by the warning Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 20:19 ` Dmitry Torokhov
2015-12-03 20:19 ` Dmitry Torokhov
2015-12-03 20:33 ` Brian Norris [this message]
2015-12-03 20:33 ` Brian Norris
[not found] ` <20151203203357.GA141945-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2015-12-03 20:35 ` Dmitry Torokhov
2015-12-03 20:35 ` Dmitry Torokhov
2015-12-03 20:35 ` Dmitry Torokhov
2015-12-20 7:50 ` Caesar Wang
2015-12-20 7:50 ` Caesar Wang
[not found] ` <1449132523-18817-1-git-send-email-wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-12-03 8:48 ` [PATCH v3 1/5] thermal: rockchip: fix a trivial typo Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` [PATCH v3 3/5] dt-bindings: rockchip-thermal: Support the RK3228/RK3399 SoCs compatible Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` [PATCH v3 4/5] thermal: rockchip: Support the RK3228 SoCs in thermal driver Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` [PATCH v3 5/5] thermal: rockchip: Support the RK3399 " Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-03 8:48 ` Caesar Wang
2015-12-17 20:09 ` [PATCH v3 0/5] Fix a trivial typo and support rk3228/rk3399 SoCs for " Eduardo Valentin
2015-12-17 20:09 ` Eduardo Valentin
[not found] ` <20151217200927.GC7999-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-12-20 9:15 ` Caesar Wang
2015-12-20 9:15 ` Caesar Wang
2015-12-20 9:15 ` Caesar Wang
2015-12-20 9:06 ` [PATCH v4 2/5] thermal: rockchip: fix a impossible condition caused by the warning Caesar Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151203203357.GA141945@google.com \
--to=computersforpeace@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=dianders@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=edubezval@gmail.com \
--cc=heiko@sntech.de \
--cc=huangtao@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=rui.zhang@intel.com \
--cc=wxt@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.