diff mbox

be2iscsi: Fix bad WARN_ON

Message ID 1443686578-13030-1-git-send-email-joel@jms.id.au (mailing list archive)
State New, archived
Headers show

Commit Message

Joel Stanley Oct. 1, 2015, 8:02 a.m. UTC
GCC 5 helpfully warns us that the WARN_ON check may be buggy:

drivers/scsi/be2iscsi/be_main.c: In function ‘be_sgl_create_contiguous’:
drivers/scsi/be2iscsi/be_main.c:3187:18: warning: logical not is only
applied to the left hand side of comparison [-Wlogical-not-parentheses]
  WARN_ON(!length > 0);
                    ^

Add the brackets that the check was was looking for.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/scsi/be2iscsi/be_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Thumshirn Oct. 1, 2015, 8:31 a.m. UTC | #1
Joel Stanley <joel@jms.id.au> writes:

> GCC 5 helpfully warns us that the WARN_ON check may be buggy:
>
> drivers/scsi/be2iscsi/be_main.c: In function ‘be_sgl_create_contiguous’:
> drivers/scsi/be2iscsi/be_main.c:3187:18: warning: logical not is only
> applied to the left hand side of comparison [-Wlogical-not-parentheses]
>   WARN_ON(!length > 0);
>                     ^
>
> Add the brackets that the check was was looking for.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
> index 7a6dbfb..0b87abb 100644
> --- a/drivers/scsi/be2iscsi/be_main.c
> +++ b/drivers/scsi/be2iscsi/be_main.c
> @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
>  {
>  	WARN_ON(!virtual_address);
>  	WARN_ON(!physical_address);
> -	WARN_ON(!length > 0);
> +	WARN_ON(!(length > 0));

Why aren't you doing WARN_ON(length <= 0); it's much nicer to read IMHO

>  	WARN_ON(!sgl);
>  
>  	sgl->va = virtual_address;
Joel Stanley Oct. 2, 2015, 12:52 a.m. UTC | #2
On Thu, Oct 1, 2015 at 6:01 PM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
>> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
>> index 7a6dbfb..0b87abb 100644
>> --- a/drivers/scsi/be2iscsi/be_main.c
>> +++ b/drivers/scsi/be2iscsi/be_main.c
>> @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
>>  {
>>       WARN_ON(!virtual_address);
>>       WARN_ON(!physical_address);
>> -     WARN_ON(!length > 0);
>> +     WARN_ON(!(length > 0));
>
> Why aren't you doing WARN_ON(length <= 0); it's much nicer to read IMHO

Sure, I'll resend.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomas Henzl Oct. 2, 2015, 12:22 p.m. UTC | #3
On 2.10.2015 02:52, Joel Stanley wrote:
> On Thu, Oct 1, 2015 at 6:01 PM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
>>> diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
>>> index 7a6dbfb..0b87abb 100644
>>> --- a/drivers/scsi/be2iscsi/be_main.c
>>> +++ b/drivers/scsi/be2iscsi/be_main.c
>>> @@ -3184,7 +3184,7 @@ be_sgl_create_contiguous(void *virtual_address,
>>>  {
>>>       WARN_ON(!virtual_address);
>>>       WARN_ON(!physical_address);
>>> -     WARN_ON(!length > 0);
>>> +     WARN_ON(!(length > 0));
>> Why aren't you doing WARN_ON(length <= 0); it's much nicer to read IMHO
> Sure, I'll resend.

length is unsigned, so maybe just (!length) ?

> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 7a6dbfb..0b87abb 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3184,7 +3184,7 @@  be_sgl_create_contiguous(void *virtual_address,
 {
 	WARN_ON(!virtual_address);
 	WARN_ON(!physical_address);
-	WARN_ON(!length > 0);
+	WARN_ON(!(length > 0));
 	WARN_ON(!sgl);
 
 	sgl->va = virtual_address;