Skip to contentSkip to conversation

block: fix possible return code clobbering in bdrv_co_pdiscard

PATCH In review Denis V. Lunev 4 participants 7 messages Jul 10, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix possible return code clobbering in bdrv_co_pdiscard

CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)
block/io.c +0 -1
index ed31810c0a..e5c6dc77d3 100644
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
         if (head) {
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Denis V. Lunev
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)

Maybe use "--noroles"? The parenthesis part is not really useful.

Quoted 20 lines
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)
block/io.c +0 -1
index ed31810c0a..e5c6dc77d3 100644
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
         if (head) {
Signature · 1 line
2.11.0
#2 lore raw
Quoted 5 lines · Fam Zheng
Quoted 3 lines · Denis V. Lunev
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)

Maybe use "--noroles"? The parenthesis part is not really useful.

good thing. May be this should be default. I have missed to clear that at commit stage.

Den

Quoted 21 lines
Quoted 20 lines
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)
block/io.c +0 -1
index ed31810c0a..e5c6dc77d3 100644
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
         if (head) {
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#3 lore raw
In reply to Denis V. Lunev
Quoted 3 lines · Denis V. Lunev
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)

The commit message is a bit sparse; I might have written:

block: fix shadowed variable in bdrv_co_pdiscard

We've had a shadowed 'ret' variable, which risks returning the wrong value, introduced in commit b9c64947.

Quoted 3 lines
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)

Adding qemu-stable in cc, and you can add:

[and I wonder why gcc doesn't flag the shadowed variable for me - I definitely touched that code in commit 9f1963b3, but didn't notice that I kept the shadowing in place. I guess we don't have that compiler warning flag turned on for default configuration]

Quoted 14 lines
block/io.c +0 -1
index ed31810c0a..e5c6dc77d3 100644
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
         if (head) {
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 10 lines · Eric Blake
Quoted 3 lines · Denis V. Lunev
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)

The commit message is a bit sparse; I might have written:

block: fix shadowed variable in bdrv_co_pdiscard

We've had a shadowed 'ret' variable, which risks returning the wrong value, introduced in commit b9c64947.

thank you for the proposal.

Den

#5 lore raw
In reply to Denis V. Lunev

Am 10.07.2017 um 10:35 hat Denis V. Lunev geschrieben:

Quoted 12 lines
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)
block/io.c +0 -0
index ed31810c0a..e5c6dc77d3 100644

block/io.c int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, · line 2469

Quoted 7 lines
block/io.c +0 -1
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
         if (head) {

Good catch, and the fix looks fine.

This needs rebasing, though (conflicts with commit f5a5ca7 'block:
change variable names in BlockDriverState').

Kevin

#6 lore raw
Quoted 19 lines · Kevin Wolf

Am 10.07.2017 um 10:35 hat Denis V. Lunev geschrieben:

Quoted 18 lines
CC Stefan Hajnoczi <[email protected]> (supporter:Block I/O path)
CC Fam Zheng <[email protected]> (supporter:Block I/O path)
---
 block/io.c | 1 -
 1 file changed, 1 deletion(-)
block/io.c +0 -1
index ed31810c0a..e5c6dc77d3 100644
@@ -2464,7 +2464,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset,
     assert(max_pdiscard >= bs->bl.request_alignment);
 
     while (count > 0) {
-        int ret;
         int num = count;
 
Quoted 7 lines

block/io.c int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, · line 2469

Quoted 1 line
block/io.c +0 -0
         if (head) {

Good catch, and the fix looks fine.

This needs rebasing, though (conflicts with commit f5a5ca7 'block:
change variable names in BlockDriverState').

Kevin

ok, will re-spin.

Den