diff mbox

[scsi] scsi: ufs: don't check unsigned type for a negative value

Message ID 20170312102202.9889-1-tomas.winkler@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Winkler, Tomas March 12, 2017, 10:22 a.m. UTC
Fix compilation warning

drivers/scsi/ufs/ufshcd.c:7645:13: warning: comparison of unsigned
expression < 0 is always false [-Wtype-limits]
if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

subhashj@codeaurora.org March 14, 2017, 12:19 a.m. UTC | #1
On 2017-03-12 03:22, Tomas Winkler wrote:
> Fix compilation warning
> 
> drivers/scsi/ufs/ufshcd.c:7645:13: warning: comparison of unsigned
> expression < 0 is always false [-Wtype-limits]
> if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 1359913bf840..e8c26e6e6237 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -7642,7 +7642,7 @@ static inline ssize_t ufshcd_pm_lvl_store(struct
> device *dev,
>  	if (kstrtoul(buf, 0, &value))
>  		return -EINVAL;
> 
> -	if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
> +	if (value >= UFS_PM_LVL_MAX)
>  		return -EINVAL;
> 
>  	spin_lock_irqsave(hba->host->host_lock, flags);

LGTM.
Reviewed-by: Subhash Jadavani <subhashj@codaurora.org>
Martin K. Petersen March 14, 2017, 3:02 a.m. UTC | #2
>>>>> "Tomas" == Tomas Winkler <tomas.winkler@intel.com> writes:

Tomas> Fix compilation warning drivers/scsi/ufs/ufshcd.c:7645:13:
Tomas> warning: comparison of unsigned expression < 0 is always false
Tomas> [-Wtype-limits] if ((value < UFS_PM_LVL_0) || (value >=
Tomas> UFS_PM_LVL_MAX))

Applied to 4.11/scsi-fixes, thanks!
James Bottomley March 15, 2017, 5:26 p.m. UTC | #3
On Mon, 2017-03-13 at 17:19 -0700, Subhash Jadavani wrote:
> On 2017-03-12 03:22, Tomas Winkler wrote:
> > Fix compilation warning
> > 
> > drivers/scsi/ufs/ufshcd.c:7645:13: warning: comparison of unsigned
> > expression < 0 is always false [-Wtype-limits]
> > if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
> > 
> > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> > ---
> >  drivers/scsi/ufs/ufshcd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> > index 1359913bf840..e8c26e6e6237 100644
> > --- a/drivers/scsi/ufs/ufshcd.c
> > +++ b/drivers/scsi/ufs/ufshcd.c
> > @@ -7642,7 +7642,7 @@ static inline ssize_t
> > ufshcd_pm_lvl_store(struct
> > device *dev,
> >  	if (kstrtoul(buf, 0, &value))
> >  		return -EINVAL;
> > 
> > -	if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
> > +	if (value >= UFS_PM_LVL_MAX)
> >  		return -EINVAL;
> > 
> >  	spin_lock_irqsave(hba->host->host_lock, flags);
> 
> LGTM.
> Reviewed-by: Subhash Jadavani <subhashj@codaurora.org>

Mis-spelling someone else's email can be cut and paste; mis-spelling
your own might be the early indications of an identity crisis.

We do cut and paste these tags, so getting your own name right for the
purposes of git history is useful.

James
subhashj@codeaurora.org March 15, 2017, 10:57 p.m. UTC | #4
On 2017-03-15 10:26, James Bottomley wrote:
> On Mon, 2017-03-13 at 17:19 -0700, Subhash Jadavani wrote:
>> On 2017-03-12 03:22, Tomas Winkler wrote:
>> > Fix compilation warning
>> >
>> > drivers/scsi/ufs/ufshcd.c:7645:13: warning: comparison of unsigned
>> > expression < 0 is always false [-Wtype-limits]
>> > if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
>> >
>> > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
>> > ---
>> >  drivers/scsi/ufs/ufshcd.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>> > index 1359913bf840..e8c26e6e6237 100644
>> > --- a/drivers/scsi/ufs/ufshcd.c
>> > +++ b/drivers/scsi/ufs/ufshcd.c
>> > @@ -7642,7 +7642,7 @@ static inline ssize_t
>> > ufshcd_pm_lvl_store(struct
>> > device *dev,
>> >  	if (kstrtoul(buf, 0, &value))
>> >  		return -EINVAL;
>> >
>> > -	if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
>> > +	if (value >= UFS_PM_LVL_MAX)
>> >  		return -EINVAL;
>> >
>> >  	spin_lock_irqsave(hba->host->host_lock, flags);
>> 
>> LGTM.
>> Reviewed-by: Subhash Jadavani <subhashj@codaurora.org>
> 
> Mis-spelling someone else's email can be cut and paste; mis-spelling
> your own might be the early indications of an identity crisis.
> 
> We do cut and paste these tags, so getting your own name right for the
> purposes of git history is useful.
> 
> James

Oops, sorry for this. If you haven't already corrected this:
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
diff mbox

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1359913bf840..e8c26e6e6237 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7642,7 +7642,7 @@  static inline ssize_t ufshcd_pm_lvl_store(struct device *dev,
 	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
-	if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
+	if (value >= UFS_PM_LVL_MAX)
 		return -EINVAL;
 
 	spin_lock_irqsave(hba->host->host_lock, flags);