* [PATCH] cgroup: avoid false positive gcc-6 warning
@ 2016-03-14 22:36 Arnd Bergmann
[not found] ` <1457994978-1057495-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2016-03-14 22:36 UTC (permalink / raw)
To: Tejun Heo, Li Zefan, Johannes Weiner
Cc: Arnd Bergmann, Aditya Kali, Aleksa Sarai,
cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
When all subsystems are disabled, gcc notices that cgroup_subsys_enabled_key
is a zero-length array and that any access to it must be out of bounds:
In file included from ../include/linux/cgroup.h:19:0,
from ../kernel/cgroup.c:31:
../kernel/cgroup.c: In function 'cgroup_add_cftypes':
../kernel/cgroup.c:261:53: error: array subscript is above array bounds [-Werror=array-bounds]
return static_key_enabled(cgroup_subsys_enabled_key[ssid]);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
../include/linux/jump_label.h:271:40: note: in definition of macro 'static_key_enabled'
static_key_count((struct static_key *)x) > 0; \
^
We should never call the function in this particular case, so this is
not a bug. In order to silence the warning, this adds an explicit check
for the CGROUP_SUBSYS_COUNT==0 case.
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
kernel/cgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 155c88470543..3348a36c3694 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -258,6 +258,9 @@ static int cgroup_addrm_files(struct cgroup_subsys_state *css,
*/
static bool cgroup_ssid_enabled(int ssid)
{
+ if (CGROUP_SUBSYS_COUNT == 0)
+ return 0;
+
return static_key_enabled(cgroup_subsys_enabled_key[ssid]);
}
--
2.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1457994978-1057495-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>]
* [PATCH] cgroup: fix boolreturn.cocci warnings [not found] ` <1457994978-1057495-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> @ 2016-03-14 23:13 ` kbuild test robot 2016-03-14 23:13 ` [PATCH] cgroup: avoid false positive gcc-6 warning kbuild test robot 1 sibling, 0 replies; 3+ messages in thread From: kbuild test robot @ 2016-03-14 23:13 UTC (permalink / raw) To: Arnd Bergmann Cc: kbuild-all-JC7UmRfGjtg, Tejun Heo, Li Zefan, Johannes Weiner, Arnd Bergmann, Aditya Kali, Aleksa Sarai, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA kernel/cgroup.c:262:9-10: WARNING: return of 0/1 in function 'cgroup_ssid_enabled' with return type bool Return statements in functions returning bool should use true/false instead of 1/0. Generated by: scripts/coccinelle/misc/boolreturn.cocci CC: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> Signed-off-by: Fengguang Wu <fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -259,7 +259,7 @@ static int cgroup_addrm_files(struct cgr static bool cgroup_ssid_enabled(int ssid) { if (CGROUP_SUBSYS_COUNT == 0) - return 0; + return false; return static_key_enabled(cgroup_subsys_enabled_key[ssid]); } ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cgroup: avoid false positive gcc-6 warning [not found] ` <1457994978-1057495-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org> 2016-03-14 23:13 ` [PATCH] cgroup: fix boolreturn.cocci warnings kbuild test robot @ 2016-03-14 23:13 ` kbuild test robot 1 sibling, 0 replies; 3+ messages in thread From: kbuild test robot @ 2016-03-14 23:13 UTC (permalink / raw) To: Arnd Bergmann Cc: kbuild-all-JC7UmRfGjtg, Tejun Heo, Li Zefan, Johannes Weiner, Arnd Bergmann, Aditya Kali, Aleksa Sarai, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Hi Arnd, [auto build test WARNING on cgroup/for-next] [also build test WARNING on v4.5 next-20160314] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Arnd-Bergmann/cgroup-avoid-false-positive-gcc-6-warning/20160315-063927 base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next coccinelle warnings: (new ones prefixed by >>) >> kernel/cgroup.c:262:9-10: WARNING: return of 0/1 in function 'cgroup_ssid_enabled' with return type bool Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-14 23:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 22:36 [PATCH] cgroup: avoid false positive gcc-6 warning Arnd Bergmann
[not found] ` <1457994978-1057495-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2016-03-14 23:13 ` [PATCH] cgroup: fix boolreturn.cocci warnings kbuild test robot
2016-03-14 23:13 ` [PATCH] cgroup: avoid false positive gcc-6 warning kbuild test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).