[libvirt] [PATCH v2 15/15] test: Refactor testNodeGetCPUMap

Peter Krempa pkrempa at redhat.com
Thu Jun 25 09:27:33 UTC 2015


On Thu, Jun 25, 2015 at 10:57:18 +0200, Pavel Hrdina wrote:
> On Wed, Jun 24, 2015 at 04:11:57PM +0200, Peter Krempa wrote:
> > Drop locking of the driver since it is not accessed and simplify the
> > code flow.
> > ---
> >  src/test/test_driver.c | 14 +++-----------
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> > 
> > diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> > index ed67dca..25de641 100644
> > --- a/src/test/test_driver.c
> > +++ b/src/test/test_driver.c
> > @@ -5611,31 +5611,23 @@ static int testConnectListAllDomains(virConnectPtr conn,
> >  }
> > 
> >  static int
> > -testNodeGetCPUMap(virConnectPtr conn,
> > +testNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
> >                    unsigned char **cpumap,
> >                    unsigned int *online,
> >                    unsigned int flags)
> >  {
> > -    testDriverPtr privconn = conn->privateData;
> > -    int ret = -1;
> > -
> >      virCheckFlags(0, -1);
> > 
> > -    testDriverLock(privconn);
> >      if (cpumap) {
> >          if (VIR_ALLOC_N(*cpumap, 1) < 0)
> > -            goto cleanup;
> > +            return -1;
> >          *cpumap[0] = 0x15;
> >      }
> > 
> >      if (online)
> >          *online = 3;
> > 
> > -    ret = 8;
> > -
> > - cleanup:
> > -    testDriverUnlock(privconn);
> > -    return ret;
> > +    return  8;
> 
> It would be nice to have a #define for that value instead of a magic number,
> but if you decide to leave it here, remove the extra space.

Well there's probably just this one usage place, so I don't think it's
worth.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150625/1950bcfd/attachment-0001.sig>


More information about the libvir-list mailing list