[libvirt] [PATCH 3/3] Convert remainder of cgroups code to report errors
Eric Blake
eblake at redhat.com
Fri Jul 19 15:31:32 UTC 2013
On 07/19/2013 08:51 AM, Daniel P. Berrange wrote:
>>> + if (virCgroupSetValueU64(group,
>>> + VIR_CGROUP_CONTROLLER_MEMORY,
>>> + filename, 1) < 0)
>>> return -1;
>>> - }
>>>
>>> return 0;
>>
>> Can code like this be simplified to:
>>
>> return virCgroupSetValueU64(group,
>> VIR_CGROUP_CONTROLLER_MEMORY,
>> filename, 1);
>
> I'm not a fan of doing that, since it means it'll be re-arranged
> again if we ever put move code in this method.
Fair enough - don't change it.
>>> - ignore_value(VIR_STRNDUP_QUIET(ret, group->controllers[i].mountPoint,
>>> - tmp - group->controllers[i].mountPoint));
>>> + if (VIR_STRNDUP(ret, group->controllers[i].mountPoint,
>>> + tmp - group->controllers[i].mountPoint) < 0)
>>> + return NULL;
>>> return ret;
>>
>> You can still use ignore_value() here rather than 'if', if desired,
>> since ret will be NULL if VIR_STRNDUP fails.
>
> I don't like that kind of use of ignore_value(). It makes it really
> easy for someone else to screw things up later by adding in more
> code between the VIR_STRNDUP & the following 'return ret'. An
> explicit 'return NULL' is safe in that scenario.
Also a reasonable explanation.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130719/cc4cea85/attachment-0001.sig>
More information about the libvir-list
mailing list