[libvirt] [PATCH v3 25/34] Adapt to VIR_STRDUP and VIR_STRNDUP in src/util/*

Eric Blake eblake at redhat.com
Mon May 20 19:02:53 UTC 2013


On 05/20/2013 06:12 AM, Michal Privoznik wrote:
>> I've only found one that doesn't:
>> src/storage/parthelper.c:
>>         if (virFileResolveLink(path, &canonical_path) != 0) {
>>
>> But you still should update the comments stating that they return 0 on success.
>>
> 
> Huh, "Returns 0 or 1 on success" is not nice. So I'd rather change the
> return value.

While the 0/1 distinction makes sense for VIR_STRDUP (as you can argue
that knowing whether the caller passed NULL is sometimes useful), most
other larger functions that happen to end on a VIR_STRDUP aren't really
using the 0/1 as a differentiation on whether the user passed in NULL,
but are always dup'ing a non-NULL string.  But returning 1 when it
conveys no real information seems awkward.  Therefore, I think I'd
rather see you rewrite code to continue to return explicit 0 on
functions that were previously returning 0, instead of optimizing by
passing the VIR_STRDUP return value straight through.

-- 
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/20130520/4c2484b0/attachment-0001.sig>


More information about the libvir-list mailing list