[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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

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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]