qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] spapr_vscsi: Set uninitialized variable


From: David Gibson
Subject: [Qemu-devel] Re: [PATCH] spapr_vscsi: Set uninitialized variable
Date: Tue, 5 Apr 2011 14:14:59 +1000
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Apr 04, 2011 at 05:03:44PM +0200, Alexander Graf wrote:
> On 04/03/2011 06:21 PM, Stefan Weil wrote:
> >cppcheck reports this error:
> >
> >hw/spapr_vscsi.c:274: error: Uninitialized variable: rc
> >
> >If llen == 0, rc was indeed used without being initialized.
> >
> >Signed-off-by: Stefan Weil<address@hidden>
> >---
> >  hw/spapr_vscsi.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> >diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
> >index e142dae..9928334 100644
> >--- a/hw/spapr_vscsi.c
> >+++ b/hw/spapr_vscsi.c
> >@@ -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.

-- 
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]