redundant code: Fix warnings reported by Clang static code analyzer
Subsystems (2)
v2 cover redundant code: Fix warnings reported by Clang static code analyzer
From: Chen Qun <[email protected]>
Since v1:
- Patch1: Addressed John Snow review comment.
- Patch12:Addressed Philippe Mathieu-Daudé review comment.
- Patch9: Move the 'dst_type' declaration to while() statement.
- Patch13: Move the 'set' declaration to the for() statement.
Chen Qun (13):
block/stream: Remove redundant statement in stream_run() block/iscsi:Remove redundant statement in iscsi_open() block/file-posix: Remove redundant statement in raw_handle_perm_lock() scsi/esp-pci: Remove redundant statement in esp_pci_io_write() scsi/scsi-disk: Remove redundant statement in
scsi_disk_emulate_command()
display/pxa2xx_lcd: Remove redundant statement in
pxa2xx_palette_parse()
display/exynos4210_fimd: Remove redundant statement in
exynos4210_fimd_update()
display/blizzard: Remove redundant statement in
blizzard_draw_line16_32()
dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
migration/vmstate: Remove redundant statement in
vmstate_save_state_v()
timer/exynos4210_mct: Remove redundant statement in
exynos4210_mct_write() usb/hcd-ehci: Remove redundant statements
monitor/hmp-cmds: Remove redundant statement in
hmp_rocker_of_dpa_groups()
block/file-posix.c | 1 - block/iscsi.c | 1 - block/stream.c | 1 - hw/display/blizzard.c | 1 - hw/display/exynos4210_fimd.c | 1 - hw/display/pxa2xx_lcd.c | 1 - hw/dma/xlnx-zdma.c | 10 +++++----- hw/scsi/esp-pci.c | 1 - hw/scsi/scsi-disk.c | 1 - hw/timer/exynos4210_mct.c | 4 ---- hw/usb/hcd-ehci.c | 3 --- migration/vmstate.c | 1 - monitor/hmp-cmds.c | 5 +---- 13 files changed, 6 insertions(+), 25 deletions(-)
Signature · 1 line
2.23.0
PATCH v2 1/13 block/stream: Remove redundant statement in stream_run()
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never read
ret = 0;
^ ~---
Cc: John Snow <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- block/stream.c | 1 - 1 file changed, 1 deletion(-)
block/stream.c +0 -1
@@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)break ; } } - ret =0 ;/* Publish progress */ job_progress_update (&s->common.job, n);
Signature · 1 line
2.23.0
Re: [PATCH v2 01/13] block/stream: Remove redundant statement in stream_run()
Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never readret = 0; ^ ~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by John Snow <[email protected]>
Let's mention that this is unnecessary since commit 1d809098aa9.
Since the same commit, the initialisation 'int ret = 0;' is unnecessary because we never read ret before overwriting the initial value. We could clean this up in the same patch.
With or without the changes:
RE: [PATCH v2 01/13] block/stream: Remove redundant statement in stream_run()
Quoted 24 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:51 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; John Snow <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 01/13] block/stream: Remove redundant statement instream_run()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never readret = 0; ^ ~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by John Snow <[email protected]>
Quoted 5 lines
Let's mention that this is unnecessary since commit
1d809098aa9.Since the same commit, the initialisation 'int ret = 0;' is unnecessary because we never read ret before overwriting the initial value. We could clean this up in the same patch.
Yes, we can clean it and move 'ret' declaration to the for() statement.
Modify just Like this:
@@ -114,7 +114,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
int64_t offset = 0;
uint64_t delay_ns = 0;
int error = 0;
- int ret = 0;
int64_t n = 0; /* bytes */
if (bs == s->bottom) {@@ -139,6 +138,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
for ( ; offset < len; offset += n) {
bool copy;+ int ret;
/* Note that even when no rate limit is applied we need to yield
* with no pending I/O here so that bdrv_drain_all() returns.
@@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
break;
}
}- ret = 0;
/* Publish progress */
job_progress_update(&s->common.job, n);Quoted 4 lines
With or without the changes:
Reviewed-by Kevin Wolf <[email protected]>
Re: [PATCH v2 01/13] block/stream: Remove redundant statement in stream_run()
Am 26.02.2020 um 11:21 hat Chenqun (kuhn) geschrieben:
Quoted 26 lines
Quoted 26 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:51 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; John Snow <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 01/13] block/stream: Remove redundant statement instream_run()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never readret = 0; ^ ~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by John Snow <[email protected]>Let's mention that this is unnecessary since commit
1d809098aa9.
Quoted 8 lines
Quoted 3 lines
Since the same commit, the initialisation 'int ret = 0;' is unnecessary because we never read ret before overwriting the initial value. We could clean this up in the same patch.
Yes, we can clean it and move 'ret' declaration to the
for()statement.Modify just Like this:
[...]
Godd point, makes sense to me. Please keep my R-b if you make this change.
Kevin
Quoted 30 lines
block/stream.c +1
-2@@ -114,7 +114,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)int64_t offset =0 ;uint64_t delay_ns =0 ;int error =0 ; -int ret =0 ;int64_t n =0 ;/* bytes */ if (bs == s->bottom) {@@ -139,6 +138,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)for ( ; offset < len; offset += n) {bool copy; +int ret;/* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. @@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error **errp)break ; } } - ret =0 ;/* Publish progress */ job_progress_update (&s->common.job, n);Quoted 5 lines
With or without the changes:
Reviewed-by Kevin Wolf <[email protected]>
RE: [PATCH v2 01/13] block/stream: Remove redundant statement in stream_run()
Quoted 44 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 6:36 PM
To: Chenqun (kuhn) <[email protected]>
Cc: John Snow <[email protected]>; [email protected]; qemu- [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 01/13] block/stream: Remove redundant statement instream_run()Am 26.02.2020 um 11:21 hat Chenqun (kuhn) geschrieben:
Quoted 32 lines
Quoted 31 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:51 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; John Snow <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 01/13] block/stream: Remove redundant statement instream_run()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/stream.c:186:9: warning: Value stored to 'ret' is never readret = 0; ^ ~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by John Snow <[email protected]>Let's mention that this is unnecessary since commit
1d809098aa9.Since the same commit, the initialisation 'int ret = 0;' is unnecessary because we never read ret before overwriting the initial value. We could clean this up in the same patch.
Quoted 6 lines
Quoted 4 lines
Yes, we can clean it and move 'ret' declaration to the
for()statement.Modify just Like this:
[...]Godd point, makes sense to me. Please keep my R-b if you make this change.
OK, no problem!
Thanks.
Quoted 36 lines
Kevin
Review static int coroutine_fn stream_run(Job *job, Error
Quoted 1 line
(quoted diff) +0
-0@@ -114,7 +114,6 @@ static int coroutine_fn stream_run(Job *job, Error**errp)
Review static int coroutine_fn stream_run(Job *job, Error
Quoted 17 lines
(quoted diff) +1
-1int64_t offset = 0; uint64_t delay_ns = 0; int error = 0; - int ret = 0; int64_t n = 0; /* bytes */ if (bs == s->bottom) {@@ -139,6 +138,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp) for ( ; offset < len; offset += n) { bool copy; + int ret; /* Note that even when no rate limit is applied we need to yield* with no pending I/O here so that
bdrv_drain_all()returns.(quoted diff) +0
-0@@ -183,7 +183,6 @@ static int coroutine_fn stream_run(Job *job, Error**errp)
Quoted 13 lines
block/stream.c +0
-1break ; } } - ret =0 ;/* Publish progress */ job_progress_update (&s->common.job, n);Quoted 5 lines
With or without the changes:
Reviewed-by Kevin Wolf <[email protected]>
PATCH v2 2/13 block/iscsi:Remove redundant statement in iscsi_open()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never read
flags &= ~BDRV_O_RDWR;
^ ~~~~~~~~~~~~---
Cc: Ronnie Sahlberg <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Peter Lieven <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- block/iscsi.c | 1 - 1 file changed, 1 deletion(-)
block/iscsi.c +0 -1
@@ -1917,7 +1917,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,if (ret <0 ) { goto out; } - flags &= ~BDRV_O_RDWR ; }iscsi_readcapacity_sync (iscsilun, &local_err);
Signature · 1 line
2.23.0
Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.
Kevin
Quoted 25 lines
Cc Ronnie Sahlberg <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Lieven <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>--- block/iscsi.c | 1 - 1 file changed, 1 deletion(-)block/iscsi.c +0
-1@@ -1917,7 +1917,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,if (ret <0 ) { goto out; } - flags &= ~BDRV_O_RDWR ; }iscsi_readcapacity_sync (iscsilun, &local_err);Signature · 1 line
2.23.0
RE: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Quoted 20 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.
Hi Kevin,
I find it exists since 8f3bf50d34037266. : )
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
It ’s okay, whether it exists or not.
Thanks.
Quoted 29 lines
Kevin
block/iscsi.c static int iscsi_open(BlockDriverState *bs, QDict
Quoted 14 lines
Cc Ronnie Sahlberg <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Lieven <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>--- block/iscsi.c | 1 - 1 file changed, 1 deletion(-)block/iscsi.c index renamed from block/iscsi.c +0
-0
682abd8e09..ed88479ede100644block/iscsi.c +0
-0@@ -1917,7 +1917,6 @@ static int iscsi_open(BlockDriverState *bs, QDict*options, int flags,
Quoted 11 lines
block/iscsi.c +0
-2if (ret <0 ) { goto out; } - flags &= ~BDRV_O_RDWR ; }iscsi_readcapacity_sync (iscsilun, &local_err); --2.23.0
Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Am 27.02.2020 um 02:49 hat Chenqun (kuhn) geschrieben:
Quoted 20 lines
Quoted 20 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.Hi Kevin,
I find it exists since8f3bf50d34037266. : )
Yes, it has existed from the start with auto-read-only.
Quoted 2 lines
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
What's interesting is that we do have one user of the flags later in the function, but it uses bs->open_flags instead:
ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
Maybe this should be using flags? (The value of the bits we're interested in is the same, but when flags is passed as a parameter, I would expect it to be used.)
Kevin
RE: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Quoted 47 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Thursday, February 27, 2020 6:31 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 27.02.2020 um 02:49 hat Chenqun (kuhn) geschrieben:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie SahlbergQuoted 14 lines
Quoted 14 lines
Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.Hi Kevin,
I find it exists since8f3bf50d34037266. : )Yes, it has existed from the start with auto-read-only.
Quoted 8 lines
Quoted 2 lines
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
What's interesting is that we do have one user of the flags later in the function, but it uses
bs->open_flagsinstead:ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
Good point, I think this is exactly where the 'flags' are needed now. It should be right to keep it for the future, too.
Later version, I will modify it.
Thanks.
Quoted 4 lines
Maybe this should be using flags? (The value of the bits we're interested in is the same, but when flags is passed as a parameter, I would expect it to be used.)
RE: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
In reply to Kevin WolfQuoted 50 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Thursday, February 27, 2020 6:31 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 27.02.2020 um 02:49 hat Chenqun (kuhn) geschrieben:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie SahlbergQuoted 14 lines
Quoted 14 lines
Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.Hi Kevin,
I find it exists since8f3bf50d34037266. : )Yes, it has existed from the start with auto-read-only.
Quoted 2 lines
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
Quoted 9 lines
What's interesting is that we do have one user of the flags later in the function, but it uses
bs->open_flagsinstead:ret = iscsi_allocmap_init(iscsilun, bs->open_flags);Maybe this should be using flags? (The value of the bits we're interested in is the same, but when flags is passed as a parameter, I would expect it to be used.)
Hi Kevin,
I have a question: are 'flags' exactly the same as 'bs-> open_flags'?
In the function bdrv_open_common() at block.c file, the existence of statement( open_flags = bdrv_open_flags(bs, bs->open_flags); ) makes them a little different. Will this place affect them inconsistently ?
Is it safer if we assign bs-> open_flags to flags?
Modify just like:
@@ -1917,7 +1917,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
if (ret < 0) {
goto out;
}
- flags &= ~BDRV_O_RDWR;
+ flags = bs->open_flags;
}
iscsi_readcapacity_sync(iscsilun, &local_err);
@@ -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);
}
}Thanks.
Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Am 28.02.2020 um 08:30 hat Chenqun (kuhn) geschrieben:
Quoted 55 lines
Quoted 55 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Thursday, February 27, 2020 6:31 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 27.02.2020 um 02:49 hat Chenqun (kuhn) geschrieben:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie SahlbergQuoted 14 lines
Quoted 14 lines
Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in the future.Hi Kevin,
I find it exists since8f3bf50d34037266. : )Yes, it has existed from the start with auto-read-only.
Quoted 2 lines
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
What's interesting is that we do have one user of the flags later in the function, but it uses
bs->open_flagsinstead:ret = iscsi_allocmap_init(iscsilun, bs->open_flags);
Quoted 8 lines
Quoted 4 lines
Maybe this should be using flags? (The value of the bits we're interested in is the same, but when flags is passed as a parameter, I would expect it to be used.)
Hi Kevin,
I have a question: are 'flags' exactly the same as 'bs->open_flags'?
In the functionbdrv_open_common()atblock.cfile, the existence ofstatement( open_flags = bdrv_open_flags(bs, bs->open_flags); )makes them a little different. Will this place affect them inconsistently ?
Not exactly the same, that's why I said "value of the bits we're interested in is the same". bdrv_open_flags() basically just filters out things that are handled by the generic block layer and none of the block driver's business.
To be precise, iscsi_allocmap_init() only checks BDRV_O_NOCACHE, which is the same in both.
Quoted 1 line
Is it safer if we assign bs->
open_flagsto flags?
This would add back the flags that we consciously filtered out before, so I would say no.
Kevin
Quoted 23 lines
Modify just like:
block/iscsi.c +2
-2@@ -1917,7 +1917,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,if (ret <0 ) { goto out; } - flags &= ~BDRV_O_RDWR ; + flags = bs->open_flags; }iscsi_readcapacity_sync (iscsilun, &local_err);@@ -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); } }Thanks.
RE: [PATCH v2 02/13] block/iscsi:Remove redundant statement in iscsi_open()
Quoted 88 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Friday, February 28, 2020 6:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie Sahlberg <[email protected]>; Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 28.02.2020 um 08:30 hat Chenqun (kuhn) geschrieben:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Thursday, February 27, 2020 6:31 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie SahlbergQuoted 30 lines
Quoted 30 lines
Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 27.02.2020 um 02:49 hat Chenqun (kuhn) geschrieben:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kevin Wolf [mailto:[email protected]]
Sent: Wednesday, February 26, 2020 5:55 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Ronnie SahlbergQuoted 14 lines
Quoted 14 lines
Paolo Bonzini <[email protected]>; Peter Lieven <[email protected]>; Max Reitz <[email protected]>
Subject: Re: [PATCH v2 02/13] block/iscsi:Remove redundant statement iniscsi_open()Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 7 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/iscsi.c:1920:9: warning: Value stored to 'flags' is never readflags &= ~BDRV_O_RDWR; ^ ~~~~~~~~~~~~Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Hmm, I'm not so sure about this one because if we remove the line, flags will be inconsistent with
bs->open_flags. It feels like setting a trap for anyone who wants to add code using flags in thefuture.
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines
Hi Kevin,
I find it exists since8f3bf50d34037266. : )Yes, it has existed from the start with auto-read-only.
Quoted 2 lines
It's not a big deal, just upset clang static code analyzer. As you said, it could be a trap for the future.
What's interesting is that we do have one user of the flags later in the function, but it uses
bs->open_flagsinstead:ret = iscsi_allocmap_init(iscsilun, bs->open_flags);Quoted 8 lines
Quoted 5 lines
Maybe this should be using flags? (The value of the bits we're interested in is the same, but when flags is passed as a parameter, I would expect it to be
used.)Hi Kevin,
I have a question: are 'flags' exactly the same as 'bs->open_flags'? In the functionbdrv_open_common()atblock.cfile, the existence of
statement( open_flags = bdrv_open_flags(bs, bs->open_flags); )makes them a little different.Quoted 1 line
Will this place affect them inconsistently ?
Not exactly the same, that's why I said "value of the bits we're interested in is the same".
bdrv_open_flags()basically just filters out things that are handled by the generic block layer and none of the block driver's business.
Quoted 8 lines
To be precise,
iscsi_allocmap_init()only checksBDRV_O_NOCACHE, which is the same in both.Quoted 1 line
Is it safer if we assign bs->
open_flagsto flags?This would add back the flags that we consciously filtered out before, so I would say no.
Well, I see, thank you very much for your detailed explanation!
Thanks.
PATCH v2 3/13 block/file-posix: Remove redundant statement in raw_handle_perm_lock()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/file-posix.c:891:9: warning: Value stored to 'op' is never read
op = RAW_PL_ABORT;
^ ~~~~~~~~~~~~---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- block/file-posix.c | 1 - 1 file changed, 1 deletion(-)
block/file-posix.c +0 -1
@@ -888,7 +888,6 @@ static int raw_handle_perm_lock(BlockDriverState *bs,"Is another process using the image [%s]?\n" , bs->filename); } - op =RAW_PL_ABORT ;/* fall through to unlock bytes. */ case RAW_PL_ABORT : raw_apply_lock_bytes(s, s->fd, s->perm, ~s->shared_perm,
Signature · 1 line
2.23.0
Re: [PATCH v2 03/13] block/file-posix: Remove redundant statement in raw_handle_perm_lock()
Am 26.02.2020 um 09:46 hat [email protected] geschrieben:
Quoted 9 lines
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
block/file-posix.c:891:9: warning: Value stored to 'op' is never readop = RAW_PL_ABORT; ^ ~~~~~~~~~~~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
PATCH v2 4/13 scsi/esp-pci: Remove redundant statement in esp_pci_io_write()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
hw/scsi/esp-pci.c:198:9: warning: Value stored to 'size' is never read
size = 4;
^ ~---
Cc: Paolo Bonzini <[email protected]>
Cc:Fam Zheng <[email protected]>
--- hw/scsi/esp-pci.c | 1 - 1 file changed, 1 deletion(-)
hw/scsi/esp-pci.c +0 -1
@@ -195,7 +195,6 @@ static void esp_pci_io_write(void *opaque, hwaddr addr, val <<= shift; val |= current & ~(mask << shift); addr &= ~3 ; - size =4 ; }if (addr <0x40 ) {
Signature · 1 line
2.23.0
PATCH v2 5/13 scsi/scsi-disk: Remove redundant statement in scsi_disk_emulate_command()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:scsi/scsi-disk.c:1918:5: warning: Value stored to 'buflen' is never read
buflen = req->cmd.xfer;
^ ~~~~~~~~~~~~~---
Cc: Paolo Bonzini <[email protected]>
Cc: Fam Zheng <[email protected]>
--- hw/scsi/scsi-disk.c | 1 - 1 file changed, 1 deletion(-)
hw/scsi/scsi-disk.c +0 -1
@@ -1915,7 +1915,6 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf) r->iov.iov_base =blk_blockalign (s->qdev.conf.blk, r->buflen); } - buflen = req->cmd.xfer; outbuf = r->iov.iov_base;memset (outbuf,0 , r->buflen);switch (req->cmd.buf[0 ]) {
Signature · 1 line
2.23.0
PATCH v2 6/13 display/pxa2xx_lcd: Remove redundant statement in pxa2xx_palette_parse()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:hw/display/pxa2xx_lcd.c:596:9: warning: Value stored to 'format' is never read
format = 0;
^ ~---
Cc: Andrzej Zaborowski <[email protected]>
Cc: Peter Maydell <[email protected]>
--- hw/display/pxa2xx_lcd.c | 1 - 1 file changed, 1 deletion(-)
hw/display/pxa2xx_lcd.c +0 -1
@@ -593,7 +593,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp) n =256 ;break ;default : - format =0 ;return ; }
Signature · 1 line
2.23.0
PATCH v2 7/13 display/exynos4210_fimd: Remove redundant statement in exynos4210_fimd_update()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:hw/display/exynos4210_fimd.c:1313:17: warning: Value stored to 'is_dirty' is never read
is_dirty = false;
---
Cc: Igor Mitsyanko <[email protected]>
Cc: Peter Maydell <[email protected]>
--- hw/display/exynos4210_fimd.c | 1 - 1 file changed, 1 deletion(-)
hw/display/exynos4210_fimd.c +0 -1
@@ -1310,7 +1310,6 @@ static void exynos4210_fimd_update(void *opaque) } host_fb_addr += inc_size; fb_line_addr += inc_size; - is_dirty = false; }g_free (snap); blend = true;
Signature · 1 line
2.23.0
PATCH v2 8/13 display/blizzard: Remove redundant statement in blizzard_draw_line16_32()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
hw/display/blizzard.c:940:9: warning: Value stored to 'data' is never read
data >>= 5;
^ ~---
Cc: Andrzej Zaborowski <[email protected]>
Cc: Peter Maydell <[email protected]>
--- hw/display/blizzard.c | 1 - 1 file changed, 1 deletion(-)
hw/display/blizzard.c +0 -1
@@ -937,7 +937,6 @@ static void blizzard_draw_line16_32(uint32_t *dest, g = (data &0x3f ) <<2 ; data >>=6 ; r = (data &0x1f ) <<3 ; - data >>=5 ; *dest++ =rgb_to_pixel32 (r, g, b); } }
Signature · 1 line
2.23.0
PATCH v2 9/13 dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never read
dst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
v1->v2: move the 'dst_type' declaration.(Base on Philippe's suggestion).
--- hw/dma/xlnx-zdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/dma/xlnx-zdma.c +5 -5
@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,static void zdma_write_dst (XlnxZDMA *s,uint8_t *buf,uint32_t len) {uint32_t dst_size, dlen; -bool dst_intr, dst_type; +bool dst_intr;unsigned int ptype =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,POINT_TYPE );unsigned int rw_mode =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,MODE ); unsigned int burst_type = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_DATA_ATTR,
@@ -387,17 +387,17 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)while (len) { dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE );if (dst_size ==0 && ptype ==PT_MEM ) {uint64_t next; +bool dst_type =FIELD_EX32 (s->dsc_dst.words[3 ], +ZDMA_CH_DST_DSCR_WORD3 , +TYPE ); + next =zdma_update_descr_addr (s, dst_type,R_ZDMA_CH_DST_CUR_DSCR_LSB );zdma_load_descriptor (s, next, &s->dsc_dst); dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE ); }/* Match what hardware does by ignoring the dst_size and only using
Signature · 1 line
2.23.0
Re: [PATCH v2 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
Quoted 46 lines · On 2/26/20 9:46 AM, [email protected] wrote:
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never readdst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
v1->v2: move the 'dst_type' declaration.(Base on Philippe's suggestion).--- hw/dma/xlnx-zdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)hw/dma/xlnx-zdma.c +5
-3@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,static void zdma_write_dst (XlnxZDMA *s,uint8_t *buf,uint32_t len) {uint32_t dst_size, dlen; -bool dst_intr, dst_type; +bool dst_intr;unsigned int ptype =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,POINT_TYPE );unsigned int rw_mode =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,MODE ); unsigned int burst_type = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_DATA_ATTR,@@ -387,17 +387,17 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)while (len) { dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE );if (dst_size ==0 && ptype ==PT_MEM ) {uint64_t next; +bool dst_type =FIELD_EX32 (s->dsc_dst.words[3 ], +ZDMA_CH_DST_DSCR_WORD3 , +TYPE ); +
hw/dma/xlnx-zdma.c static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len) · line 403
Quoted 10 lines
hw/dma/xlnx-zdma.c +0
-2next =zdma_update_descr_addr (s, dst_type,R_ZDMA_CH_DST_CUR_DSCR_LSB );zdma_load_descriptor (s, next, &s->dsc_dst); dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE ); }/* Match what hardware does by ignoring the dst_size and only using
Re: [PATCH v2 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
In reply to [email protected]Quoted 9 lines · On [2020 Feb 26] Wed 16:46:43, [email protected] wrote:
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never readdst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
Quoted 51 lines
---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
v1->v2: move the 'dst_type' declaration.(Base on Philippe's suggestion).--- hw/dma/xlnx-zdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)hw/dma/xlnx-zdma.c +5
-5@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,static void zdma_write_dst (XlnxZDMA *s,uint8_t *buf,uint32_t len) {uint32_t dst_size, dlen; -bool dst_intr, dst_type; +bool dst_intr;unsigned int ptype =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,POINT_TYPE );unsigned int rw_mode =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,MODE ); unsigned int burst_type = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_DATA_ATTR,@@ -387,17 +387,17 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)while (len) { dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE );if (dst_size ==0 && ptype ==PT_MEM ) {uint64_t next; +bool dst_type =FIELD_EX32 (s->dsc_dst.words[3 ], +ZDMA_CH_DST_DSCR_WORD3 , +TYPE ); + next =zdma_update_descr_addr (s, dst_type,R_ZDMA_CH_DST_CUR_DSCR_LSB );zdma_load_descriptor (s, next, &s->dsc_dst); dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE ); }/* Match what hardware does by ignoring the dst_size and only using Signature · 1 line
2.23.0
Re: [PATCH v2 09/13] dma/xlnx-zdma: Remove redundant statement in zdma_write_dst()
In reply to [email protected]Quoted 8 lines · On Wed, Feb 26, 2020 at 12:52 AM <[email protected]> wrote:
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
hw/dma/xlnx-zdma.c:399:13: warning: Value stored to 'dst_type' is never readdst_type = FIELD_EX32(s->dsc_dst.words[3], ZDMA_CH_DST_DSCR_WORD3, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>---
Cc: Alistair Francis <[email protected]>
Cc: "Edgar E. Iglesias" <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 46 lines
v1->v2: move the 'dst_type' declaration.(Base on Philippe's suggestion).--- hw/dma/xlnx-zdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)hw/dma/xlnx-zdma.c +5
-6@@ -373,7 +373,7 @@ static uint64_t zdma_update_descr_addr(XlnxZDMA *s, bool type,static void zdma_write_dst (XlnxZDMA *s,uint8_t *buf,uint32_t len) {uint32_t dst_size, dlen; -bool dst_intr, dst_type; +bool dst_intr;unsigned int ptype =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,POINT_TYPE );unsigned int rw_mode =ARRAY_FIELD_EX32 (s->regs,ZDMA_CH_CTRL0 ,MODE ); unsigned int burst_type = ARRAY_FIELD_EX32(s->regs, ZDMA_CH_DATA_ATTR,@@ -387,17 +387,17 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, uint32_t len)while (len) { dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE );if (dst_size ==0 && ptype ==PT_MEM ) {uint64_t next; +bool dst_type =FIELD_EX32 (s->dsc_dst.words[3 ], +ZDMA_CH_DST_DSCR_WORD3 , +TYPE ); + next =zdma_update_descr_addr (s, dst_type,R_ZDMA_CH_DST_CUR_DSCR_LSB );zdma_load_descriptor (s, next, &s->dsc_dst); dst_size =FIELD_EX32 (s->dsc_dst.words[2 ],ZDMA_CH_DST_DSCR_WORD2 ,SIZE ); - dst_type =FIELD_EX32 (s->dsc_dst.words[3 ],ZDMA_CH_DST_DSCR_WORD3 , -TYPE ); }/* Match what hardware does by ignoring the dst_size and only using -- 2.23.0
PATCH v2 10/13 migration/vmstate: Remove redundant statement in vmstate_save_state_v()
In reply to [email protected]From: Chen Qun <[email protected]>
The "ret" has been assigned in all branches. It didn't need to be
assigned separately.
Clang static code analyzer show warning:
migration/vmstate.c:365:17: warning: Value stored to 'ret' is never read
ret = 0;
^ ~---
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
--- migration/vmstate.c | 1 - 1 file changed, 1 deletion(-)
migration/vmstate.c +0 -1
@@ -362,7 +362,6 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd, }for (i =0 ; i < n_elems; i++) {void *curr_elem = first_elem + size * i; - ret =0 ;vmsd_desc_field_start (vmsd, vmdesc_loop, field, i, n_elems); old_offset =qemu_ftell_fast (f);
Signature · 1 line
2.23.0
Re: [PATCH v2 10/13] migration/vmstate: Remove redundant statement in vmstate_save_state_v()
Quoted 5 lines · <[email protected]> wrote:
From: Chen Qun <[email protected]>
The "ret" has been assigned in all branches. It didn't need to be
assigned separately.
Quoted 7 lines
Clang static code analyzer show warning:
migration/vmstate.c:365:17: warning: Value stored to 'ret' is never readret = 0; ^ ~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
I thought I had already reviewed it.
queued
PATCH v2 11/13 timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is never read
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is never read
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is never read
index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~---
Cc: Igor Mitsyanko <[email protected]>
Cc: Peter Maydell <[email protected]>
--- hw/timer/exynos4210_mct.c | 4 ---- 1 file changed, 4 deletions(-)
hw/timer/exynos4210_mct.c +0 -4
@@ -1367,7 +1367,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,case L0_TCNTB :case L1_TCNTB : lt_i =GET_L_TIMER_IDX (offset); - index =GET_L_TIMER_CNT_REG_IDX (offset, lt_i);/* * TCNTB is updated to internal register only after CNT expired.
@@ -1396,7 +1395,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,case L0_ICNTB :case L1_ICNTB : lt_i =GET_L_TIMER_IDX (offset); - index =GET_L_TIMER_CNT_REG_IDX (offset, lt_i); s->l_timer[lt_i].reg.wstat |=L_WSTAT_ICNTB_WRITE ; s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
@@ -1438,8 +1436,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,case L0_FRCNTB :case L1_FRCNTB : lt_i =GET_L_TIMER_IDX (offset); - index =GET_L_TIMER_CNT_REG_IDX (offset, lt_i); -DPRINTF ("local timer[%d] FRCNTB write %llx\n" , lt_i, value); s->l_timer[lt_i].reg.wstat |=L_WSTAT_FRCCNTB_WRITE ;
Signature · 1 line
2.23.0
PATCH v2 12/13 usb/hcd-ehci: Remove redundant statements
In reply to [email protected]From: Chen Qun <[email protected]>
The "again" assignment is meaningless before g_assert_not_reached. In addition, the break statements no longer needs to be after g_assert_not_reached.
Clang static code analyzer show warning:hw/usb/hcd-ehci.c:2108:13: warning: Value stored to 'again' is never read
again = -1;
^ ~~---
Cc: Gerd Hoffmann <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
--- hw/usb/hcd-ehci.c | 3 --- 1 file changed, 3 deletions(-)
hw/usb/hcd-ehci.c +0 -3
@@ -1301,7 +1301,6 @@ static void ehci_execute_complete(EHCIQueue *q)/* should not be triggerable */ fprintf (stderr,"USB invalid response %d\n" , p->packet.status);g_assert_not_reached (); -break ; }/* TODO check 4.12 for splits */
@@ -2105,9 +2104,7 @@ static void ehci_advance_state(EHCIState *ehci, int async)default :fprintf (stderr,"Bad state!\n" ); - again =-1 ;g_assert_not_reached (); -break ; }if (again <0 || itd_count >16 ) {
Signature · 1 line
2.23.0
Re: [PATCH v2 12/13] usb/hcd-ehci: Remove redundant statements
Quoted 6 lines · On Wed, Feb 26, 2020 at 04:46:46PM +0800, [email protected] wrote:
From: Chen Qun <[email protected]>
The "again" assignment is meaningless before
g_assert_not_reached. In addition, the break statements no longer needs to be afterg_assert_not_reached.
Quoted 8 lines
Clang static code analyzer show warning:
hw/usb/hcd-ehci.c:2108:13: warning: Value stored to 'again' is never readagain = -1; ^ ~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Patch added to usb queue.
thanks,
Gerd
PATCH v2 13/13 monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()
In reply to [email protected]From: Chen Qun <[email protected]>
Clang static code analyzer show warning:monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never read
set = true;
^ ~~~~---
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
v1->v2: move the 'set' declaration to the for() statement(Base on Philippe's suggestion).
--- monitor/hmp-cmds.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
monitor/hmp-cmds.c +1 -4
@@ -2808,7 +2808,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)const char *name =qdict_get_str (qdict,"name" );uint8_t type =qdict_get_try_int (qdict,"type" ,9 );Error *err =NULL ; -bool set = false; list =qmp_query_rocker_of_dpa_groups (name, type !=9 , type, &err);if (err !=NULL ) {
@@ -2820,6 +2819,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)for (g = list; g; g = g->next) {RockerOfDpaGroup *group = g->value; +bool set = false;monitor_printf (mon,"0x%08x" , group->id);
@@ -2864,14 +2864,11 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)if (group->has_set_eth_dst) {if (!set) { - set = true;monitor_printf (mon," set" ); }monitor_printf (mon," dst %s" , group->set_eth_dst); } - set = false; -if (group->has_ttl_check && group->ttl_check) {monitor_printf (mon," check TTL" ); }
Signature · 1 line
2.23.0
Re: [PATCH v2 13/13] monitor/hmp-cmds: Remove redundant statement in hmp_rocker_of_dpa_groups()
Quoted 44 lines · On 2/26/20 9:46 AM, [email protected] wrote:
From: Chen Qun <[email protected]>
Clang static code analyzer show warning:
monitor/hmp-cmds.c:2867:17: warning: Value stored to 'set' is never readset = true; ^ ~~~~Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>---
Cc: "Dr. David Alan Gilbert" <[email protected]>
Cc: Philippe Mathieu-Daudé <[email protected]>
v1->v2: move the 'set' declaration to thefor()statement(Base on Philippe's suggestion).--- monitor/hmp-cmds.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)monitor/hmp-cmds.c +1
-2@@ -2808,7 +2808,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)const char *name =qdict_get_str (qdict,"name" );uint8_t type =qdict_get_try_int (qdict,"type" ,9 );Error *err =NULL ; -bool set = false; list =qmp_query_rocker_of_dpa_groups (name, type !=9 , type, &err);if (err !=NULL ) {@@ -2820,6 +2819,7 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)for (g = list; g; g = g->next) {RockerOfDpaGroup *group = g->value; +bool set = false;monitor_printf (mon,"0x%08x" , group->id);@@ -2864,14 +2864,11 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)if (group->has_set_eth_dst) {if (!set) { - set = true;
monitor/hmp-cmds.c void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict) · line 2874
Quoted 10 lines
monitor/hmp-cmds.c +0
-2monitor_printf (mon," set" ); }monitor_printf (mon," dst %s" , group->set_eth_dst); } - set = false; -if (group->has_ttl_check && group->ttl_check) {monitor_printf (mon," check TTL" ); }