diff mbox series

[v3] block/iscsi:use the flags in iscsi_open() prevent Clang warning

Message ID 20200311032927.35092-1-kuhn.chenqun@huawei.com
State New
Headers show
Series [v3] block/iscsi:use the flags in iscsi_open() prevent Clang warning | expand

Commit Message

Chenqun (kuhn) March 11, 2020, 3:29 a.m. UTC
Clang static code analyzer show warning:
  block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
        flags &= ~BDRV_O_RDWR;
        ^        ~~~~~~~~~~~~

In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which
is the same in both of flags and bs->open_flags.
We can use the flags instead bs->open_flags to prevent Clang warning.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Lieven <pl@kamp.de>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Laurent Vivier <laurent@vivier.eu>

v1->v2:
 Keep the 'flags' then use it(Base on Kevin's comments).

v2->v3:
 Modify subject and commit messages(Base on Kevin's and Laurent's comments).
---
 block/iscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chenqun (kuhn) March 20, 2020, 2:25 a.m. UTC | #1
Gentle ping.

Any other suggestions about this?

Thanks.

>-----Original Message-----
>From: Chenqun (kuhn)
>Sent: Wednesday, March 11, 2020 11:29 AM
>To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
>Cc: Zhanghailiang <zhang.zhanghailiang@huawei.com>; Chenqun (kuhn)
><kuhn.chenqun@huawei.com>; Euler Robot <euler.robot@huawei.com>;
>Kevin Wolf <kwolf@redhat.com>; Ronnie Sahlberg
><ronniesahlberg@gmail.com>; Paolo Bonzini <pbonzini@redhat.com>; Peter
>Lieven <pl@kamp.de>; Max Reitz <mreitz@redhat.com>; Laurent Vivier
><laurent@vivier.eu>
>Subject: [PATCH v3] block/iscsi:use the flags in iscsi_open() prevent Clang
>warning
>
>Clang static code analyzer show warning:
>  block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
>        flags &= ~BDRV_O_RDWR;
>        ^        ~~~~~~~~~~~~
>
>In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which is the same in
>both of flags and bs->open_flags.
>We can use the flags instead bs->open_flags to prevent Clang warning.
>
>Reported-by: Euler Robot <euler.robot@huawei.com>
>Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>Reviewed-by: Kevin Wolf <kwolf@redhat.com>
>---
>Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
>Cc: Paolo Bonzini <pbonzini@redhat.com>
>Cc: Peter Lieven <pl@kamp.de>
>Cc: Kevin Wolf <kwolf@redhat.com>
>Cc: Max Reitz <mreitz@redhat.com>
>Cc: Laurent Vivier <laurent@vivier.eu>
>
>v1->v2:
> Keep the 'flags' then use it(Base on Kevin's comments).
>
>v2->v3:
> Modify subject and commit messages(Base on Kevin's and Laurent's
>comments).
>---
> block/iscsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/block/iscsi.c b/block/iscsi.c index 682abd8e09..50bae51700 100644
>--- a/block/iscsi.c
>+++ b/block/iscsi.c
>@@ -2002,7 +2002,7 @@ static int iscsi_open(BlockDriverState *bs, QDict
>*options, int flags,
>         iscsilun->cluster_size = iscsilun->bl.opt_unmap_gran *
>             iscsilun->block_size;
>         if (iscsilun->lbprz) {
>-            ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
>+            ret = iscsi_allocmap_init(iscsilun, flags);
>         }
>     }
>
>--
>2.23.0
>
Laurent Vivier March 20, 2020, 9:20 a.m. UTC | #2
Le 20/03/2020 à 03:25, Chenqun (kuhn) a écrit :
> Gentle ping.
> 
> Any other suggestions about this?

I will not take that via the trivial queue as it is not trivial for me.

Could it go via block queue?

Thanks,
Laurent

> Thanks.
> 
>> -----Original Message-----
>> From: Chenqun (kuhn)
>> Sent: Wednesday, March 11, 2020 11:29 AM
>> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
>> Cc: Zhanghailiang <zhang.zhanghailiang@huawei.com>; Chenqun (kuhn)
>> <kuhn.chenqun@huawei.com>; Euler Robot <euler.robot@huawei.com>;
>> Kevin Wolf <kwolf@redhat.com>; Ronnie Sahlberg
>> <ronniesahlberg@gmail.com>; Paolo Bonzini <pbonzini@redhat.com>; Peter
>> Lieven <pl@kamp.de>; Max Reitz <mreitz@redhat.com>; Laurent Vivier
>> <laurent@vivier.eu>
>> Subject: [PATCH v3] block/iscsi:use the flags in iscsi_open() prevent Clang
>> warning
>>
>> Clang static code analyzer show warning:
>>  block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
>>        flags &= ~BDRV_O_RDWR;
>>        ^        ~~~~~~~~~~~~
>>
>> In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which is the same in
>> both of flags and bs->open_flags.
>> We can use the flags instead bs->open_flags to prevent Clang warning.
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>> Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> Cc: Peter Lieven <pl@kamp.de>
>> Cc: Kevin Wolf <kwolf@redhat.com>
>> Cc: Max Reitz <mreitz@redhat.com>
>> Cc: Laurent Vivier <laurent@vivier.eu>
>>
>> v1->v2:
>> Keep the 'flags' then use it(Base on Kevin's comments).
>>
>> v2->v3:
>> Modify subject and commit messages(Base on Kevin's and Laurent's
>> comments).
>> ---
>> block/iscsi.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/block/iscsi.c b/block/iscsi.c index 682abd8e09..50bae51700 100644
>> --- a/block/iscsi.c
>> +++ b/block/iscsi.c
>> @@ -2002,7 +2002,7 @@ static int iscsi_open(BlockDriverState *bs, QDict
>> *options, int flags,
>>         iscsilun->cluster_size = iscsilun->bl.opt_unmap_gran *
>>             iscsilun->block_size;
>>         if (iscsilun->lbprz) {
>> -            ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
>> +            ret = iscsi_allocmap_init(iscsilun, flags);
>>         }
>>     }
>>
>> --
>> 2.23.0
>>
>
Stefan Hajnoczi March 20, 2020, 2:04 p.m. UTC | #3
On Wed, Mar 11, 2020 at 11:29:27AM +0800, Chen Qun wrote:
> Clang static code analyzer show warning:
>   block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
>         flags &= ~BDRV_O_RDWR;
>         ^        ~~~~~~~~~~~~
> 
> In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which
> is the same in both of flags and bs->open_flags.
> We can use the flags instead bs->open_flags to prevent Clang warning.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>

This can go via Paolo's SCSI tree.

> ---
> Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Peter Lieven <pl@kamp.de>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> 
> v1->v2:
>  Keep the 'flags' then use it(Base on Kevin's comments).
> 
> v2->v3:
>  Modify subject and commit messages(Base on Kevin's and Laurent's comments).
> ---
>  block/iscsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 682abd8e09..50bae51700 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -2002,7 +2002,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
>          iscsilun->cluster_size = iscsilun->bl.opt_unmap_gran *
>              iscsilun->block_size;
>          if (iscsilun->lbprz) {
> -            ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
> +            ret = iscsi_allocmap_init(iscsilun, flags);
>          }
>      }
>  
> -- 
> 2.23.0
> 
> 
>
Kevin Wolf March 23, 2020, 4:58 p.m. UTC | #4
Am 11.03.2020 um 04:29 hat Chen Qun geschrieben:
> Clang static code analyzer show warning:
>   block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
>         flags &= ~BDRV_O_RDWR;
>         ^        ~~~~~~~~~~~~
> 
> In iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which
> is the same in both of flags and bs->open_flags.
> We can use the flags instead bs->open_flags to prevent Clang warning.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>

Thanks, applied to the block branch.

Kevin
diff mbox series

Patch

diff --git a/block/iscsi.c b/block/iscsi.c
index 682abd8e09..50bae51700 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2002,7 +2002,7 @@  static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
         iscsilun->cluster_size = iscsilun->bl.opt_unmap_gran *
             iscsilun->block_size;
         if (iscsilun->lbprz) {
-            ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
+            ret = iscsi_allocmap_init(iscsilun, flags);
         }
     }