[libvirt] [PATCH 1/4] character device: Allow character devices to have different target types

Matthew Booth mbooth at redhat.com
Wed Nov 4 16:16:15 UTC 2009


On 04/11/09 11:19, Richard W.M. Jones wrote:
> On Tue, Nov 03, 2009 at 04:07:38PM +0000, Matthew Booth wrote:
>> @@ -1325,6 +1332,7 @@ virDomainChrDefParseXML(virConnectPtr conn,
>>       char *path = NULL;
>>       char *mode = NULL;
>>       char *protocol = NULL;
>> +    const char *targetType = NULL;
>>       virDomainChrDefPtr def;
>>
>>       if (VIR_ALLOC(def)<  0) {
>
> Patch looks good to me.  I'm going to be a bit picky though and say
> that if you unconditionally initialize variables when they are
> declared, as in the hunk above, then you prevent the compiler from
> detecting when you use a variable without first initializing it.

In this particular case the initialisation is required. The reason is 
that we unconditionally free the variable in the cleanup lower down. 
This pattern means we can 'goto error' and not worry about leaking 
objects which may or may not have been allocated.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:       +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490




More information about the libvir-list mailing list