Re: [PATCH] cgroup: use uninitialized_var() for may-be uninitialized variable

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

 



On 2014/4/22 13:44, Jianyu Zhan wrote:
> To suppress this warning:
> 
>  warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>   int err;
> 	^

I don't see this warning, and I don't see how this is possible.

static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)
{
	struct cgroup *parent = cgrp->parent;
	struct cgroup_subsys_state *css;
	int err;

	lockdep_assert_held(&cgroup_mutex);

	css = ss->css_alloc(cgroup_css(parent, ss));
	if (IS_ERR(css))
		return PTR_ERR(css);

	err = percpu_ref_init(&css->refcnt, css_release);
	if (err)
		goto err_free_css;
	...

	return err;
}

> 
> Use the uninitialized_var() to decalre err. It also serves to be good documetation.
> 

anyway, uninitialized_var() should be avoided if possible.

nack

> Signed-off-by: Jianyu Zhan <nasa4836@xxxxxxxxx>
> ---
>  kernel/cgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 24675f5..930569c 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -4144,7 +4144,7 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)
>  {
>  	struct cgroup *parent = cgrp->parent;
>  	struct cgroup_subsys_state *css;
> -	int err;
> +	int uninitialized_var(err);
>  
>  	lockdep_assert_held(&cgroup_mutex);
>  
> 

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/containers





[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux