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

Laine Stump laine at laine.org
Fri Sep 4 17:41:40 UTC 2015


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 at redhat.com>
> ---
>   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)

?

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





More information about the libvir-list mailing list