* [PATCH stable-4.1.y] tools include: Add a __fallthrough statement
@ 2017-10-27 19:05 Florian Fainelli
2017-10-30 3:03 ` Levin, Alexander (Sasha Levin)
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2017-10-27 19:05 UTC (permalink / raw)
To: linux-kernel
Cc: alexander.levin, stable, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan, William Cohen,
Greg Kroah-Hartman, Florian Fainelli
From: Arnaldo Carvalho de Melo <acme@redhat.com>
commit b5bf1733d6a391c4e90ea8f8468d83023be74a2a upstream.
For cases where implicit fall through case labels are intended,
to let us inform that to gcc >= 7:
CC /tmp/build/perf/util/string.o
util/string.c: In function 'perf_atoll':
util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (*p)
^
util/string.c:24:3: note: here
case '\0':
^~~~
So we introduce:
#define __fallthrough __attribute__ ((fallthrough))
And use it in such cases.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/n/tip-qnpig0xfop4hwv6k4mv1wts5@git.kernel.org
Fixes: ed8306908374 ("perf top: Use __fallthrough")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
tools/include/linux/compiler.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 88461f09cc86..8717c80f759c 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -37,4 +37,12 @@
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
+#ifndef __fallthrough
+# if defined(__GNUC__) && __GNUC__ >= 7
+# define __fallthrough __attribute__ ((fallthrough))
+# else
+# define __fallthrough
+# endif
+#endif
+
#endif /* _TOOLS_LINUX_COMPILER_H */
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH stable-4.1.y] tools include: Add a __fallthrough statement
2017-10-27 19:05 [PATCH stable-4.1.y] tools include: Add a __fallthrough statement Florian Fainelli
@ 2017-10-30 3:03 ` Levin, Alexander (Sasha Levin)
0 siblings, 0 replies; 2+ messages in thread
From: Levin, Alexander (Sasha Levin) @ 2017-10-30 3:03 UTC (permalink / raw)
To: Florian Fainelli
Cc: linux-kernel, stable, Arnaldo Carvalho de Melo, Adrian Hunter,
David Ahern, Jiri Olsa, Namhyung Kim, Wang Nan, William Cohen,
Greg Kroah-Hartman
On Fri, Oct 27, 2017 at 12:05:58PM -0700, Florian Fainelli wrote:
>From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
>commit b5bf1733d6a391c4e90ea8f8468d83023be74a2a upstream.
>
>For cases where implicit fall through case labels are intended,
>to let us inform that to gcc >= 7:
>
> CC /tmp/build/perf/util/string.o
> util/string.c: In function 'perf_atoll':
> util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
> if (*p)
> ^
> util/string.c:24:3: note: here
> case '\0':
> ^~~~
>
>So we introduce:
>
> #define __fallthrough __attribute__ ((fallthrough))
>
>And use it in such cases.
Queued up, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-30 3:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 19:05 [PATCH stable-4.1.y] tools include: Add a __fallthrough statement Florian Fainelli
2017-10-30 3:03 ` Levin, Alexander (Sasha Levin)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.