Coverity fixes
cover Coverity fixes
Paul Durrant (3):
dataplane/xen-block: remove dead code
xen-block: remove redundant assignment
xen-block: report error condition from vbd_name_to_disk()
hw/block/dataplane/xen-block.c | 5 +---- hw/block/xen-block.c | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-)
---
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Signature · 7 lines
2.20.1.2.gb21ebb6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/3 dataplane/xen-block: remove dead code
The if() statement is clearly bogus (dead code which should have been cleaned up when grant mapping was removed).
Spotted by Coverity: CID 1398635
While in the neighbourhood, add a missing 'fall through' annotation.
---
Cc: Stefan Hajnoczi <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- hw/block/dataplane/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/block/dataplane/xen-block.c +1 -4
@@ -281,10 +281,6 @@ static void xen_block_complete_aio(void *opaque, int ret)break ;case BLKIF_OP_WRITE :case BLKIF_OP_FLUSH_DISKCACHE : -if (!request->req.nr_segments) { -break ; - } -break ;default :break ; }
@@ -298,6 +294,7 @@ static void xen_block_complete_aio(void *opaque, int ret)if (!request->req.nr_segments) {break ; } +/* fall through */ case BLKIF_OP_READ :if (request->status ==BLKIF_RSP_OKAY ) {block_acct_done (blk_get_stats (dataplane->blk), &request->acct);
Signature · 7 lines
2.20.1.2.gb21ebb6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH 1/3] dataplane/xen-block: remove dead code
Quoted 2 lines · Paul Durrant
The
if()statement is clearly bogus (dead code which should have been cleaned up when grant mapping was removed).
"... was removed in 06454c24ad)."
Quoted 34 lines
Spotted by Coverity: CID 1398635
While in the neighbourhood, add a missing 'fall through' annotation.
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>---
Cc: Stefan Hajnoczi <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>--- hw/block/dataplane/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/dataplane/xen-block.c +0
-4@@ -281,10 +281,6 @@ static void xen_block_complete_aio(void *opaque, int ret)break ;case BLKIF_OP_WRITE :case BLKIF_OP_FLUSH_DISKCACHE : -if (!request->req.nr_segments) { -break ; - } -break ;default :break ; }
hw/block/dataplane/xen-block.c static void xen_block_complete_aio(void *opaque, int ret) · line 300
Quoted 7 lines
hw/block/dataplane/xen-block.c +1
-0@@ -298,6 +294,7 @@ static void xen_block_complete_aio(void *opaque, int ret)if (!request->req.nr_segments) {break ; } +/* fall through */ case BLKIF_OP_READ :if (request->status ==BLKIF_RSP_OKAY ) {block_acct_done (blk_get_stats (dataplane->blk), &request->acct);
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH 1/3] dataplane/xen-block: remove dead code
In reply to Paul DurrantQuoted 2 lines · Paul Durrant
The
if()statement is clearly bogus (dead code which should have been cleaned up when grant mapping was removed).
"... was removed in 06454c24ad)."
Quoted 41 lines
Spotted by Coverity: CID 1398635
While in the neighbourhood, add a missing 'fall through' annotation.
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>---
Cc: Stefan Hajnoczi <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>--- hw/block/dataplane/xen-block.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)hw/block/dataplane/xen-block.c +1
-4@@ -281,10 +281,6 @@ static void xen_block_complete_aio(void *opaque, int ret)break ;case BLKIF_OP_WRITE :case BLKIF_OP_FLUSH_DISKCACHE : -if (!request->req.nr_segments) { -break ; - } -break ;default :break ; }@@ -298,6 +294,7 @@ static void xen_block_complete_aio(void *opaque, int ret)if (!request->req.nr_segments) {break ; } +/* fall through */ case BLKIF_OP_READ :if (request->status ==BLKIF_RSP_OKAY ) {block_acct_done (blk_get_stats (dataplane->blk), &request->acct);
Anthony PERARD
Acked-byRe: [Qemu-devel] [PATCH 1/3] dataplane/xen-block: remove dead code
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Paul Durrant
The
if()statement is clearly bogus (dead code which should have been cleaned up when grant mapping was removed)."... was removed in
06454c24ad)."
Actually, it looks like c6025bd197 should have remove the if statement.
Quoted 7 lines
Quoted 7 lines
Spotted by Coverity: CID 1398635
While in the neighbourhood, add a missing 'fall through' annotation.
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>
Thanks,
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/3 xen-block: remove redundant assignment
In reply to Paul DurrantThe assignment to 'p' is unnecessary as the code will either goto 'invalid' or p will get overwritten.
Spotted by Coverity: CID 1398638
---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- hw/block/xen-block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/block/xen-block.c +1 -2
@@ -413,8 +413,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, }if (*end =='p' ) { - p = (char *) ++end; -if (*end =='\0' ) { +if (*(++end) =='\0' ) { goto invalid; } }
Signature · 7 lines
2.20.1.2.gb21ebb6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/3 xen-block: remove redundant assignment
In reply to Paul DurrantThe assignment to 'p' is unnecessary as the code will either goto 'invalid' or p will get overwritten.
Spotted by Coverity: CID 1398638
---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- hw/block/xen-block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/block/xen-block.c +1 -2
@@ -413,8 +413,7 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, }if (*end =='p' ) { - p = (char *) ++end; -if (*end =='\0' ) { +if (*(++end) =='\0' ) { goto invalid; } }
Signature · 1 line
2.20.1.2.gb21ebb6
Re: [Qemu-devel] [PATCH 2/3] xen-block: remove redundant assignment
Quoted 7 lines · Paul Durrant
The assignment to 'p' is unnecessary as the code will either goto 'invalid' or p will get overwritten.
Spotted by Coverity: CID 1398638
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/3 xen-block: report error condition from vbd_name_to_disk()
In reply to Paul DurrantThe function needs to make sure it is passed a valid disk name. This is easily done by making sure that the parsing loop results in a non-zero value.
Spotted by Coverity: CID 1398640
---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
--- hw/block/xen-block.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
hw/block/xen-block.c +15 -6
@@ -351,21 +351,28 @@ static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name,g_free (str); } -static unsigned int vbd_name_to_disk (const char *name,const char **endp) +static int vbd_name_to_disk (const char *name,const char **endp, +unsigned long *disk) { -unsigned int disk =0 ; +unsigned int n =0 ;while (*name !='\0' ) {if (!g_ascii_isalpha (*name) || !g_ascii_islower (*name)) {break ; } - disk *=26 ; - disk += *name++ -'a' +1 ; + n *=26 ; + n += *name++ -'a' +1 ; } *endp = name; -return disk -1 ; +if (!n) { +return -1 ; + } + + *disk = n -1 ; + +return 0 ; } static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name,
@@ -418,7 +425,9 @@ static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, } } }else { - vdev->disk =vbd_name_to_disk (p, &end); +if (vbd_name_to_disk (p, &end, &vdev->disk)) { + goto invalid; + } }if (*end !='\0' ) {
Signature · 7 lines
2.20.1.2.gb21ebb6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Qemu-devel] [PATCH 3/3] xen-block: report error condition from vbd_name_to_disk()
Quoted 8 lines · Paul Durrant
The function needs to make sure it is passed a valid disk name. This is easily done by making sure that the parsing loop results in a non-zero value.
Spotted by Coverity: CID 1398640
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH 3/3] xen-block: report error condition from vbd_name_to_disk()
In reply to Paul DurrantQuoted 8 lines · Paul Durrant
The function needs to make sure it is passed a valid disk name. This is easily done by making sure that the parsing loop results in a non-zero value.
Spotted by Coverity: CID 1398640
Reported-by Peter Maydell <[email protected]>Signed-off-by Paul Durrant <[email protected]>
Thanks,
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel