[libvirt] [PATCH 2/5] commandtest: Resolve some coverity resource leaks

Eric Blake eblake at redhat.com
Fri Feb 15 15:44:40 UTC 2013


On 02/15/2013 08:12 AM, John Ferlan wrote:
> On 02/15/2013 08:54 AM, Peter Krempa wrote:
>> On 02/15/13 14:17, Eric Blake wrote:
>>> On 02/15/2013 02:01 AM, Peter Krempa wrote:
>>>
>>>>> So, one could logically believe the check could change to:
>>>>>
>>>>>       sa_assert(fd == -1 || (fd >= 3 && fd <= 8));
>>>
>>> Yes, I like that.
>>
>> If I understood it correctly, the above condition won't shut up
>> coverity, only sa_assert(fd == -1) does as coverity then thinks that fd
>> was > 8 and thus closed. Otherwise it does not detect the magic we're
>> doing later.
> 
> Yes, correct, hence the need for the "/* coverity[overwrite_var] */ tag.

If you're using the /* coverity[overwrite_var] */ tag, then do we still
need the sa_assert?  This is one case where leaving comments to shut up
coverity is fair game, because it is a test program, and because we
already know we are doing some unusual games with fds to get into a
known state.

-- 
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/20130215/c44e0b3b/attachment-0001.sig>


More information about the libvir-list mailing list