spapr_vscsi: Set uninitialized variable
PATCH 1/1 spapr_vscsi: Set uninitialized variable
cppcheck reports this error:
hw/spapr_vscsi.c:274: error: Uninitialized variable: rc
If llen == 0, rc was indeed used without being initialized.
--- hw/spapr_vscsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/spapr_vscsi.c +1 -1
@@ -255,7 +255,7 @@ static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req, {struct srp_direct_buf *md = req->cur_desc;uint32_t llen; -int rc; +int rc =0 ;dprintf ("VSCSI: direct segment 0x%x bytes, va=0x%llx desc len=0x%x\n" , len, (unsigned long long )md->va, md->len);
Signature · 1 line
1.7.2.5
Quoted 16 lines · Stefan Weil
cppcheck reports this error:
hw/spapr_vscsi.c:274: error: Uninitialized variable: rcIf llen == 0, rc was indeed used without being initialized.
Signed-off-by Stefan Weil<[email protected]>--- hw/spapr_vscsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/spapr_vscsi.c +0
-0
hw/spapr_vscsi.c static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req, · line 258
Quoted 5 lines
hw/spapr_vscsi.c +1
-1@@ -255,7 +255,7 @@ static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req, {struct srp_direct_buf *md = req->cur_desc;uint32_t llen; -int rc; +int rc =0 ;
David, is this correct? Or would rc be -1 when !llen?
Alex
Quoted 12 lines · Alexander Graf
Quoted 11 lines · Stefan Weil
cppcheck reports this error:
hw/spapr_vscsi.c:274: error: Uninitialized variable: rcIf llen == 0, rc was indeed used without being initialized.
Signed-off-by Stefan Weil<[email protected]>--- hw/spapr_vscsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 12 lines
hw/spapr_vscsi.c static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req, · line 258
Quoted 10 lines
hw/spapr_vscsi.c +1
-1@@ -255,7 +255,7 @@ static int vscsi_srp_direct_data(VSCSIState *s, vscsi_req *req, {struct srp_direct_buf *md = req->cur_desc;uint32_t llen; -int rc; +int rc =0 ;David, is this correct? Or would rc be -1 when !llen?
I talked to Ben, who wrote this code - apparently his mail server blew up. This patch should be correct, AFAWCT. It's not totally clear what the right return value should be in thie case, or indeed that this case ever actually happens, but we think 0 is right.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 8 lines · David Gibson
Quoted 1 line
Review static int vscsi_srp_direct_data(VSCSIState *s,
Quoted 1 line
(quoted diff) +0
-0@@ -255,7 +255,7 @@ static int vscsi_srp_direct_data(VSCSIState *s,
vscsi_req*req,Quoted 6 lines
Quoted 5 lines
hw/spapr_vscsi.c +1
-1{struct srp_direct_buf *md = req->cur_desc;uint32_t llen; -int rc; +int rc =0 ;
Quoted 6 lines
Quoted 1 line
David, is this correct? Or would rc be -1 when !llen?
I talked to Ben, who wrote this code - apparently his mail server blew up. This patch should be correct, AFAWCT. It's not totally clear what the right return value should be in thie case, or indeed that this case ever actually happens, but we think 0 is right.
Just double checked and we never call that function if len is 0
Cheers,
Ben.
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 8 lines · David Gibson
Quoted 1 line
Review static int vscsi_srp_direct_data(VSCSIState *s,
Quoted 1 line
(quoted diff) +0
-0@@ -255,7 +255,7 @@ static int vscsi_srp_direct_data(VSCSIState *s,
vscsi_req*req,Quoted 6 lines
Quoted 5 lines
hw/spapr_vscsi.c +1
-1{struct srp_direct_buf *md = req->cur_desc;uint32_t llen; -int rc; +int rc =0 ;
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
David, is this correct? Or would rc be -1 when !llen?
I talked to Ben, who wrote this code - apparently his mail server blew up. This patch should be correct, AFAWCT. It's not totally clear what the right return value should be in thie case, or indeed that this case ever actually happens, but we think 0 is right.
Just double checked and we never call that function if len is 0
That's probably the reason gcc didn't complain before. So I'll just take Stefan's patch.
Alex