* [PATCH] cgroup: use uninitialized_var() for may-be uninitialized variable
@ 2014-04-22 5:44 Jianyu Zhan
[not found] ` <1398145479-11400-1-git-send-email-nasa4836-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Jianyu Zhan @ 2014-04-22 5:44 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A, lizefan-hv44wF8Li93QT0dZR+AlfA
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
nasa4836-Re5JQEeQqe8AvxtiuMwx3w
To suppress this warning:
warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized]
int err;
^
Use the uninitialized_var() to decalre err. It also serves to be good documetation.
Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
---
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);
--
2.0.0-rc0
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/containers
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1398145479-11400-1-git-send-email-nasa4836-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] cgroup: use uninitialized_var() for may-be uninitialized variable [not found] ` <1398145479-11400-1-git-send-email-nasa4836-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2014-04-22 6:26 ` Li Zefan [not found] ` <53560BA3.40501-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Li Zefan @ 2014-04-22 6:26 UTC (permalink / raw) To: Jianyu Zhan Cc: tj-DgEjT+Ai2ygdnm+yROfE0A, cgroups-u79uwXL29TY76Z2rM5mHXA, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA 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@gmail.com> > --- > 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@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/containers ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <53560BA3.40501-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] cgroup: use uninitialized_var() for may-be uninitialized variable [not found] ` <53560BA3.40501-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> @ 2014-04-22 7:52 ` Jianyu Zhan 0 siblings, 0 replies; 3+ messages in thread From: Jianyu Zhan @ 2014-04-22 7:52 UTC (permalink / raw) To: Li Zefan Cc: Tejun Heo, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Cgroups, LKML Hi, Li, On Tue, Apr 22, 2014 at 2:26 PM, Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> wrote: > > I don't see this warning, and I don't see how this is possible. You are right. No such warning. It is triggered by the other patch, should be fixed in that patch. Thanks, Jianyu Zhan ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-22 7:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-22 5:44 [PATCH] cgroup: use uninitialized_var() for may-be uninitialized variable Jianyu Zhan
[not found] ` <1398145479-11400-1-git-send-email-nasa4836-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-22 6:26 ` Li Zefan
[not found] ` <53560BA3.40501-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2014-04-22 7:52 ` Jianyu Zhan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox