[libvirt] [PATCH] deprecate fclose() and introduce VIR_{FORCE_}FCLOSE()

Eric Blake eblake at redhat.com
Fri Nov 12 17:50:50 UTC 2010


On 11/12/2010 10:47 AM, Stefan Berger wrote:
>>> -    if (list)
>>> -        fclose(list);
>>> -    else
>>> -        VIR_FORCE_CLOSE(fd);
>>> +    VIR_FORCE_FCLOSE(list);
>>> +    VIR_FORCE_CLOSE(fd);
>> You just introduced a double close.  list was created via fdopen(fd),
> :-( In that case, what about wrapping fdopen with FDOPEN and set fd to
> -1 if the function succeeds, i.e., returns != NULL?
>> which effectively consumes fd.  Maybe we need to add VIR_FDOPEN which
>> auto-sets an fdopen'd fd to -1 on success?  Maybe not, but then you need
>> to adjust the fdopen() call site to invalidate fd so we don't re-close
>> it.

Sounds like we're in violent agreement. :)

VIR_FDOPEN sounds good to me; and only 5 places that call fdopen, so you
might as well fold it into your next spin of this patch.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101112/688dc190/attachment-0001.sig>


More information about the libvir-list mailing list