Re: [PATCH 2/5] lxc: Avoid Coverity SIZEOF_MISMATCH

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

 




On 09/04/2015 01:41 PM, Laine Stump wrote:
> On 09/04/2015 10:30 AM, John Ferlan wrote:
>> Commit id '692e9fac7' used virProcessSetNamespaces instead of inlining
>> the similar functionality; however, Coverity notes that the function
>> prototype expects a size_t value and not an enum and complains. So,
>> just pass as a size_t to avoid the noise.
>>
>> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
>> ---
>>   src/lxc/lxc_container.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> 
> This file needs the copyright date updated to include 2015 (no I don't
> go around checking for that; I have an emacs hook that complains about
> it any time I save a file.)
> 
>> index a433552..062da68 100644
>> --- a/src/lxc/lxc_container.c
>> +++ b/src/lxc/lxc_container.c
>> @@ -2150,8 +2150,8 @@ static int
>> lxcContainerDropCapabilities(virDomainDefPtr def ATTRIBUTE_UNUSED,
>>    */
>>   static int lxcAttachNS(int *ns_fd)
>>   {
>> -    if (ns_fd &&
>> -        virProcessSetNamespaces(VIR_LXC_DOMAIN_NAMESPACE_LAST, ns_fd)
>> < 0)
>> +    size_t nfdlist = VIR_LXC_DOMAIN_NAMESPACE_LAST;
>> +    if (ns_fd && virProcessSetNamespaces(nfdlist, ns_fd) < 0)
> 
> Doesn't it work if you just add a typecast in the call:
> 
>    virProcessSetNamespaces((size_t)VIR_LXC_DOMAIN_NAMESPACE_LAST, ns_fd)
> 
> ?
> 

Yes typecasting works - some like it, some don't - so I played it safe
with a new variable.

John
> Assuming there's a reason for the way you did it vs. this, ACK with the
> copyright updated.
> 
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]