blob: 5b5edc5319173d8b92d3933a46de8318b18292a8 [file] [log] [blame]
Patrick Williams93c203f2021-10-06 16:15:23 -05001From c570be0da77e963d77bac099d468bc0cd5f1bd63 Mon Sep 17 00:00:00 2001
2From: Michael Jeanson <mjeanson@efficios.com>
3Date: Mon, 13 Sep 2021 14:16:22 -0400
4Subject: [PATCH 2/2] fix: Revert "Makefile: Enable -Wimplicit-fallthrough for
5 Clang" (v5.15)
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Starting with v5.15, "-Wimplicit-fallthrough=5" was added to the build
11flags which requires the use of "__attribute__((__fallthrough__))" to
12annotate fallthrough case statements.
13
14See upstream commit by the man himself:
15
16 commit d936eb23874433caa3e3d841cfa16f5434b85dcf
17 Author: Linus Torvalds <torvalds@linux-foundation.org>
18 Date: Thu Jul 15 18:05:31 2021 -0700
19
20 Revert "Makefile: Enable -Wimplicit-fallthrough for Clang"
21
22 This reverts commit b7eb335e26a9c7f258c96b3962c283c379d3ede0.
23
24 It turns out that the problem with the clang -Wimplicit-fallthrough
25 warning is not about the kernel source code, but about clang itself, and
26 that the warning is unusable until clang fixes its broken ways.
27
28 In particular, when you enable this warning for clang, you not only get
29 warnings about implicit fallthroughs. You also get this:
30
31 warning: fallthrough annotation in unreachable code [-Wimplicit-fallthrough]
32
33 which is completely broken becasue it
34
35 (a) doesn't even tell you where the problem is (seriously: no line
36 numbers, no filename, no nothing).
37
38 (b) is fundamentally broken anyway, because there are perfectly valid
39 reasons to have a fallthrough statement even if it turns out that
40 it can perhaps not be reached.
41
42 In the kernel, an example of that second case is code in the scheduler:
43
44 switch (state) {
45 case cpuset:
46 if (IS_ENABLED(CONFIG_CPUSETS)) {
47 cpuset_cpus_allowed_fallback(p);
48 state = possible;
49 break;
50 }
51 fallthrough;
52 case possible:
53
54 where if CONFIG_CPUSETS is enabled you actually never hit the
55 fallthrough case at all. But that in no way makes the fallthrough
56 wrong.
57
58 So the warning is completely broken, and enabling it for clang is a very
59 bad idea.
60
61 In the meantime, we can keep the gcc option enabled, and make the gcc
62 build use
63
64 -Wimplicit-fallthrough=5
65
66 which means that we will at least continue to require a proper
67 fallthrough statement, and that gcc won't silently accept the magic
68 comment versions. Because gcc does this all correctly, and while the odd
69 "=5" part is kind of obscure, it's documented in [1]:
70
71 "-Wimplicit-fallthrough=5 doesn’t recognize any comments as
72 fallthrough comments, only attributes disable the warning"
73
74 so if clang ever fixes its bad behavior we can try enabling it there again.
75
76Upstream-Status: backport [https://git.lttng.org/?p=lttng-modules.git;a=commit;h=c190d76e8c7b44d62b3651ab845b765c1b1f8104]
77
78Change-Id: Iea69849592fb69ac04fb9bb28efcd6b8dce8ba88
79Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
80Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
81---
82 include/counter/counter-api.h | 4 +-
83 include/lttng/events-internal.h | 11 ++-
84 include/wrapper/compiler_attributes.h | 34 +++++++
85 src/lib/counter/counter.c | 13 ++-
86 src/lttng-abi.c | 91 ++++++++++++------
87 src/lttng-bytecode-interpreter.c | 4 +-
88 src/lttng-bytecode-specialize.c | 5 +-
89 src/lttng-events.c | 129 +++++++++++++++++---------
90 src/lttng-string-utils.c | 3 +-
91 src/probes/lttng-kretprobes.c | 7 +-
92 10 files changed, 215 insertions(+), 86 deletions(-)
93 create mode 100644 include/wrapper/compiler_attributes.h
94
95diff --git a/include/counter/counter-api.h b/include/counter/counter-api.h
96index fbc65818..c9f2b141 100644
97--- a/include/counter/counter-api.h
98+++ b/include/counter/counter-api.h
99@@ -15,6 +15,7 @@
100 #include <linux/bitops.h>
101 #include <counter/counter.h>
102 #include <counter/counter-internal.h>
103+#include <wrapper/compiler_attributes.h>
104 #include <wrapper/limits.h>
105
106 /*
107@@ -256,7 +257,8 @@ static __always_inline int lttng_counter_add(const struct lib_counter_config *co
108 const size_t *dimension_indexes, int64_t v)
109 {
110 switch (config->alloc) {
111- case COUNTER_ALLOC_PER_CPU: /* Fallthrough */
112+ case COUNTER_ALLOC_PER_CPU:
113+ lttng_fallthrough;
114 case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL:
115 return __lttng_counter_add_percpu(config, counter, dimension_indexes, v);
116 case COUNTER_ALLOC_GLOBAL:
117diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h
118index cd560de8..ca2190c4 100644
119--- a/include/lttng/events-internal.h
120+++ b/include/lttng/events-internal.h
121@@ -8,6 +8,8 @@
122 #ifndef _LTTNG_EVENTS_INTERNAL_H
123 #define _LTTNG_EVENTS_INTERNAL_H
124
125+#include <wrapper/compiler_attributes.h>
126+
127 #include <lttng/events.h>
128
129 struct lttng_syscall_filter;
130@@ -561,9 +563,12 @@ static inline bool lttng_kernel_type_is_bytewise_integer(const struct lttng_kern
131 if (!type_integer)
132 return false;
133 switch (type_integer->size) {
134- case 8: /* Fall-through. */
135- case 16: /* Fall-through. */
136- case 32: /* Fall-through. */
137+ case 8:
138+ lttng_fallthrough;
139+ case 16:
140+ lttng_fallthrough;
141+ case 32:
142+ lttng_fallthrough;
143 case 64:
144 break;
145 default:
146diff --git a/include/wrapper/compiler_attributes.h b/include/wrapper/compiler_attributes.h
147new file mode 100644
148index 00000000..c2c96e76
149--- /dev/null
150+++ b/include/wrapper/compiler_attributes.h
151@@ -0,0 +1,34 @@
152+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
153+ *
154+ * wrapper/compiler_attributes.h
155+ *
156+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
157+ */
158+
159+#ifndef _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H
160+#define _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H
161+
162+#include <lttng/kernel-version.h>
163+
164+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,20,0))
165+#include <linux/compiler_attributes.h>
166+#endif
167+
168+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0))
169+
170+/*
171+ * Use the kernel provided fallthrough attribute macro.
172+ */
173+#define lttng_fallthrough fallthrough
174+
175+#else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */
176+
177+/*
178+ * Fallback to the comment for kernels pre 5.15 that don't build with
179+ * '-Wimplicit-fallthrough=5'.
180+ */
181+#define lttng_fallthrough do {} while (0) /* fallthrough */
182+
183+#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */
184+
185+#endif /* _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H */
186diff --git a/src/lib/counter/counter.c b/src/lib/counter/counter.c
187index a4500a0e..bf038aac 100644
188--- a/src/lib/counter/counter.c
189+++ b/src/lib/counter/counter.c
190@@ -11,6 +11,7 @@
191 #include <linux/cpumask.h>
192 #include <counter/counter.h>
193 #include <counter/counter-internal.h>
194+#include <wrapper/compiler_attributes.h>
195 #include <wrapper/vmalloc.h>
196 #include <wrapper/limits.h>
197
198@@ -324,7 +325,8 @@ int lttng_counter_aggregate(const struct lib_counter_config *config,
199 *underflow = false;
200
201 switch (config->alloc) {
202- case COUNTER_ALLOC_GLOBAL: /* Fallthrough */
203+ case COUNTER_ALLOC_GLOBAL:
204+ lttng_fallthrough;
205 case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL:
206 /* Read global counter. */
207 ret = lttng_counter_read(config, counter, dimension_indexes,
208@@ -342,7 +344,8 @@ int lttng_counter_aggregate(const struct lib_counter_config *config,
209 switch (config->alloc) {
210 case COUNTER_ALLOC_GLOBAL:
211 break;
212- case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL: /* Fallthrough */
213+ case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL:
214+ lttng_fallthrough;
215 case COUNTER_ALLOC_PER_CPU:
216 //TODO: integrate with CPU hotplug and online cpus
217 for (cpu = 0; cpu < num_possible_cpus(); cpu++) {
218@@ -448,7 +451,8 @@ int lttng_counter_clear(const struct lib_counter_config *config,
219 int cpu, ret;
220
221 switch (config->alloc) {
222- case COUNTER_ALLOC_GLOBAL: /* Fallthrough */
223+ case COUNTER_ALLOC_GLOBAL:
224+ lttng_fallthrough;
225 case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL:
226 /* Clear global counter. */
227 ret = lttng_counter_clear_cpu(config, counter, dimension_indexes, -1);
228@@ -462,7 +466,8 @@ int lttng_counter_clear(const struct lib_counter_config *config,
229 switch (config->alloc) {
230 case COUNTER_ALLOC_GLOBAL:
231 break;
232- case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL: /* Fallthrough */
233+ case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL:
234+ lttng_fallthrough;
235 case COUNTER_ALLOC_PER_CPU:
236 //TODO: integrate with CPU hotplug and online cpus
237 for (cpu = 0; cpu < num_possible_cpus(); cpu++) {
238diff --git a/src/lttng-abi.c b/src/lttng-abi.c
239index cc453894..eac1afd1 100644
240--- a/src/lttng-abi.c
241+++ b/src/lttng-abi.c
242@@ -34,6 +34,7 @@
243 #include <ringbuffer/vfs.h>
244 #include <ringbuffer/backend.h>
245 #include <ringbuffer/frontend.h>
246+#include <wrapper/compiler_attributes.h>
247 #include <wrapper/poll.h>
248 #include <wrapper/file.h>
249 #include <wrapper/kref.h>
250@@ -1332,7 +1333,8 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
251 */
252 return -ENOSYS;
253 }
254- case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */
255+ case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY:
256+ lttng_fallthrough;
257 case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH:
258 {
259 struct lttng_metadata_stream *stream = filp->private_data;
260@@ -1441,7 +1443,8 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
261 */
262 return -ENOSYS;
263 }
264- case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */
265+ case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH_EMPTY:
266+ lttng_fallthrough;
267 case LTTNG_KERNEL_ABI_RING_BUFFER_FLUSH:
268 {
269 struct lttng_metadata_stream *stream = filp->private_data;
270@@ -1758,8 +1761,10 @@ int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param)
271 switch (event_param->instrumentation) {
272 case LTTNG_KERNEL_ABI_SYSCALL:
273 switch (event_param->u.syscall.entryexit) {
274- case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: /* Fall-through */
275- case LTTNG_KERNEL_ABI_SYSCALL_EXIT: /* Fall-through */
276+ case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
277+ lttng_fallthrough;
278+ case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
279+ lttng_fallthrough;
280 case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
281 break;
282 default:
283@@ -1783,20 +1788,26 @@ int lttng_abi_validate_event_param(struct lttng_kernel_abi_event *event_param)
284 switch (event_param->u.kretprobe.entryexit) {
285 case LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT:
286 break;
287- case LTTNG_KERNEL_ABI_SYSCALL_ENTRY: /* Fall-through */
288- case LTTNG_KERNEL_ABI_SYSCALL_EXIT: /* Fall-through */
289+ case LTTNG_KERNEL_ABI_SYSCALL_ENTRY:
290+ lttng_fallthrough;
291+ case LTTNG_KERNEL_ABI_SYSCALL_EXIT:
292+ lttng_fallthrough;
293 default:
294 return -EINVAL;
295 }
296 break;
297
298- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
299- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
300+ case LTTNG_KERNEL_ABI_TRACEPOINT:
301+ lttng_fallthrough;
302+ case LTTNG_KERNEL_ABI_KPROBE:
303+ lttng_fallthrough;
304 case LTTNG_KERNEL_ABI_UPROBE:
305 break;
306
307- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
308- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
309+ case LTTNG_KERNEL_ABI_FUNCTION:
310+ lttng_fallthrough;
311+ case LTTNG_KERNEL_ABI_NOOP:
312+ lttng_fallthrough;
313 default:
314 return -EINVAL;
315 }
316@@ -1830,18 +1841,23 @@ int lttng_abi_create_event(struct file *channel_file,
317 }
318
319 switch (event_param->instrumentation) {
320- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
321+ case LTTNG_KERNEL_ABI_TRACEPOINT:
322+ lttng_fallthrough;
323 case LTTNG_KERNEL_ABI_SYSCALL:
324 fops = &lttng_event_recorder_enabler_fops;
325 break;
326- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
327- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
328+ case LTTNG_KERNEL_ABI_KPROBE:
329+ lttng_fallthrough;
330+ case LTTNG_KERNEL_ABI_KRETPROBE:
331+ lttng_fallthrough;
332 case LTTNG_KERNEL_ABI_UPROBE:
333 fops = &lttng_event_recorder_event_fops;
334 break;
335
336- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
337- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
338+ case LTTNG_KERNEL_ABI_FUNCTION:
339+ lttng_fallthrough;
340+ case LTTNG_KERNEL_ABI_NOOP:
341+ lttng_fallthrough;
342 default:
343 return -EINVAL;
344 }
345@@ -1867,7 +1883,8 @@ int lttng_abi_create_event(struct file *channel_file,
346 goto event_error;
347
348 switch (event_param->instrumentation) {
349- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
350+ case LTTNG_KERNEL_ABI_TRACEPOINT:
351+ lttng_fallthrough;
352 case LTTNG_KERNEL_ABI_SYSCALL:
353 {
354 struct lttng_event_enabler *event_enabler;
355@@ -1887,8 +1904,10 @@ int lttng_abi_create_event(struct file *channel_file,
356 break;
357 }
358
359- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
360- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
361+ case LTTNG_KERNEL_ABI_KPROBE:
362+ lttng_fallthrough;
363+ case LTTNG_KERNEL_ABI_KRETPROBE:
364+ lttng_fallthrough;
365 case LTTNG_KERNEL_ABI_UPROBE:
366 {
367 struct lttng_kernel_event_recorder *event;
368@@ -1908,8 +1927,10 @@ int lttng_abi_create_event(struct file *channel_file,
369 break;
370 }
371
372- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
373- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
374+ case LTTNG_KERNEL_ABI_FUNCTION:
375+ lttng_fallthrough;
376+ case LTTNG_KERNEL_ABI_NOOP:
377+ lttng_fallthrough;
378 default:
379 ret = -EINVAL;
380 goto event_error;
381@@ -2043,18 +2064,23 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
382 }
383
384 switch (event_notifier_param->event.instrumentation) {
385- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
386+ case LTTNG_KERNEL_ABI_TRACEPOINT:
387+ lttng_fallthrough;
388 case LTTNG_KERNEL_ABI_SYSCALL:
389 fops = &lttng_event_notifier_enabler_fops;
390 break;
391- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
392- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
393+ case LTTNG_KERNEL_ABI_KPROBE:
394+ lttng_fallthrough;
395+ case LTTNG_KERNEL_ABI_KRETPROBE:
396+ lttng_fallthrough;
397 case LTTNG_KERNEL_ABI_UPROBE:
398 fops = &lttng_event_notifier_event_fops;
399 break;
400
401- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
402- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
403+ case LTTNG_KERNEL_ABI_FUNCTION:
404+ lttng_fallthrough;
405+ case LTTNG_KERNEL_ABI_NOOP:
406+ lttng_fallthrough;
407 default:
408 ret = -EINVAL;
409 goto inval_instr;
410@@ -2086,7 +2112,8 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
411 goto event_notifier_error;
412
413 switch (event_notifier_param->event.instrumentation) {
414- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
415+ case LTTNG_KERNEL_ABI_TRACEPOINT:
416+ lttng_fallthrough;
417 case LTTNG_KERNEL_ABI_SYSCALL:
418 {
419 struct lttng_event_notifier_enabler *enabler;
420@@ -2110,8 +2137,10 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
421 break;
422 }
423
424- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
425- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
426+ case LTTNG_KERNEL_ABI_KPROBE:
427+ lttng_fallthrough;
428+ case LTTNG_KERNEL_ABI_KRETPROBE:
429+ lttng_fallthrough;
430 case LTTNG_KERNEL_ABI_UPROBE:
431 {
432 struct lttng_kernel_event_notifier *event_notifier;
433@@ -2135,8 +2164,10 @@ int lttng_abi_create_event_notifier(struct file *event_notifier_group_file,
434 break;
435 }
436
437- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
438- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
439+ case LTTNG_KERNEL_ABI_FUNCTION:
440+ lttng_fallthrough;
441+ case LTTNG_KERNEL_ABI_NOOP:
442+ lttng_fallthrough;
443 default:
444 ret = -EINVAL;
445 goto event_notifier_error;
446diff --git a/src/lttng-bytecode-interpreter.c b/src/lttng-bytecode-interpreter.c
447index b46a23b7..a2a932c6 100644
448--- a/src/lttng-bytecode-interpreter.c
449+++ b/src/lttng-bytecode-interpreter.c
450@@ -7,6 +7,7 @@
451 * Copyright (C) 2010-2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
452 */
453
454+#include <wrapper/compiler_attributes.h>
455 #include <wrapper/uaccess.h>
456 #include <wrapper/objtool.h>
457 #include <wrapper/types.h>
458@@ -421,7 +422,8 @@ static int dynamic_get_index(struct lttng_kernel_probe_ctx *lttng_probe_ctx,
459 }
460 break;
461 case LOAD_ROOT_CONTEXT:
462- case LOAD_ROOT_APP_CONTEXT: /* Fall-through */
463+ lttng_fallthrough;
464+ case LOAD_ROOT_APP_CONTEXT:
465 {
466 ret = context_get_index(lttng_probe_ctx,
467 &stack_top->u.ptr,
468diff --git a/src/lttng-bytecode-specialize.c b/src/lttng-bytecode-specialize.c
469index c4b9d04b..f8b5f19d 100644
470--- a/src/lttng-bytecode-specialize.c
471+++ b/src/lttng-bytecode-specialize.c
472@@ -8,6 +8,8 @@
473 */
474
475 #include <linux/slab.h>
476+#include <wrapper/compiler_attributes.h>
477+
478 #include <lttng/lttng-bytecode.h>
479 #include <lttng/align.h>
480 #include <lttng/events-internal.h>
481@@ -271,7 +273,8 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
482 }
483 case OBJECT_TYPE_STRUCT:
484 /* Only generated by the specialize phase. */
485- case OBJECT_TYPE_VARIANT: /* Fall-through */
486+ case OBJECT_TYPE_VARIANT:
487+ lttng_fallthrough;
488 default:
489 printk(KERN_WARNING "LTTng: bytecode: Unexpected get index type %d",
490 (int) stack_top->load.object_type);
491diff --git a/src/lttng-events.c b/src/lttng-events.c
492index e785fe4d..230e3934 100644
493--- a/src/lttng-events.c
494+++ b/src/lttng-events.c
495@@ -28,6 +28,7 @@
496 #include <linux/vmalloc.h>
497 #include <linux/dmi.h>
498
499+#include <wrapper/compiler_attributes.h>
500 #include <wrapper/uuid.h>
501 #include <wrapper/vmalloc.h> /* for wrapper_vmalloc_sync_mappings() */
502 #include <wrapper/random.h>
503@@ -659,12 +660,14 @@ int lttng_event_enable(struct lttng_kernel_event_common *event)
504 goto end;
505 }
506 switch (event->priv->instrumentation) {
507- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
508+ case LTTNG_KERNEL_ABI_TRACEPOINT:
509+ lttng_fallthrough;
510 case LTTNG_KERNEL_ABI_SYSCALL:
511 ret = -EINVAL;
512 break;
513
514- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
515+ case LTTNG_KERNEL_ABI_KPROBE:
516+ lttng_fallthrough;
517 case LTTNG_KERNEL_ABI_UPROBE:
518 WRITE_ONCE(event->enabled, 1);
519 break;
520@@ -673,8 +676,10 @@ int lttng_event_enable(struct lttng_kernel_event_common *event)
521 ret = lttng_kretprobes_event_enable_state(event, 1);
522 break;
523
524- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
525- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
526+ case LTTNG_KERNEL_ABI_FUNCTION:
527+ lttng_fallthrough;
528+ case LTTNG_KERNEL_ABI_NOOP:
529+ lttng_fallthrough;
530 default:
531 WARN_ON_ONCE(1);
532 ret = -EINVAL;
533@@ -719,12 +724,14 @@ int lttng_event_disable(struct lttng_kernel_event_common *event)
534 goto end;
535 }
536 switch (event->priv->instrumentation) {
537- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
538+ case LTTNG_KERNEL_ABI_TRACEPOINT:
539+ lttng_fallthrough;
540 case LTTNG_KERNEL_ABI_SYSCALL:
541 ret = -EINVAL;
542 break;
543
544- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
545+ case LTTNG_KERNEL_ABI_KPROBE:
546+ lttng_fallthrough;
547 case LTTNG_KERNEL_ABI_UPROBE:
548 WRITE_ONCE(event->enabled, 0);
549 break;
550@@ -733,8 +740,10 @@ int lttng_event_disable(struct lttng_kernel_event_common *event)
551 ret = lttng_kretprobes_event_enable_state(event, 0);
552 break;
553
554- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
555- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
556+ case LTTNG_KERNEL_ABI_FUNCTION:
557+ lttng_fallthrough;
558+ case LTTNG_KERNEL_ABI_NOOP:
559+ lttng_fallthrough;
560 default:
561 WARN_ON_ONCE(1);
562 ret = -EINVAL;
563@@ -873,15 +882,20 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l
564 event_name = event_desc->event_name;
565 break;
566
567- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
568- case LTTNG_KERNEL_ABI_UPROBE: /* Fall-through */
569- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
570+ case LTTNG_KERNEL_ABI_KPROBE:
571+ lttng_fallthrough;
572+ case LTTNG_KERNEL_ABI_UPROBE:
573+ lttng_fallthrough;
574+ case LTTNG_KERNEL_ABI_KRETPROBE:
575+ lttng_fallthrough;
576 case LTTNG_KERNEL_ABI_SYSCALL:
577 event_name = event_param->name;
578 break;
579
580- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
581- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
582+ case LTTNG_KERNEL_ABI_FUNCTION:
583+ lttng_fallthrough;
584+ case LTTNG_KERNEL_ABI_NOOP:
585+ lttng_fallthrough;
586 default:
587 WARN_ON_ONCE(1);
588 ret = -EINVAL;
589@@ -1093,8 +1107,10 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l
590 WARN_ON_ONCE(!ret);
591 break;
592
593- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
594- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
595+ case LTTNG_KERNEL_ABI_FUNCTION:
596+ lttng_fallthrough;
597+ case LTTNG_KERNEL_ABI_NOOP:
598+ lttng_fallthrough;
599 default:
600 WARN_ON_ONCE(1);
601 ret = -EINVAL;
602@@ -1141,15 +1157,20 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
603 event_name = event_desc->event_name;
604 break;
605
606- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
607- case LTTNG_KERNEL_ABI_UPROBE: /* Fall-through */
608+ case LTTNG_KERNEL_ABI_KPROBE:
609+ lttng_fallthrough;
610+ case LTTNG_KERNEL_ABI_UPROBE:
611+ lttng_fallthrough;
612 case LTTNG_KERNEL_ABI_SYSCALL:
613 event_name = event_notifier_param->event.name;
614 break;
615
616- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
617- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
618- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
619+ case LTTNG_KERNEL_ABI_KRETPROBE:
620+ lttng_fallthrough;
621+ case LTTNG_KERNEL_ABI_FUNCTION:
622+ lttng_fallthrough;
623+ case LTTNG_KERNEL_ABI_NOOP:
624+ lttng_fallthrough;
625 default:
626 WARN_ON_ONCE(1);
627 ret = -EINVAL;
628@@ -1296,9 +1317,12 @@ struct lttng_kernel_event_notifier *_lttng_event_notifier_create(
629 WARN_ON_ONCE(!ret);
630 break;
631
632- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
633- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
634- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
635+ case LTTNG_KERNEL_ABI_KRETPROBE:
636+ lttng_fallthrough;
637+ case LTTNG_KERNEL_ABI_FUNCTION:
638+ lttng_fallthrough;
639+ case LTTNG_KERNEL_ABI_NOOP:
640+ lttng_fallthrough;
641 default:
642 WARN_ON_ONCE(1);
643 ret = -EINVAL;
644@@ -1423,14 +1447,18 @@ void register_event(struct lttng_kernel_event_recorder *event_recorder)
645 ret = lttng_syscall_filter_enable_event(event_recorder->chan, event_recorder);
646 break;
647
648- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
649- case LTTNG_KERNEL_ABI_UPROBE: /* Fall-through */
650+ case LTTNG_KERNEL_ABI_KPROBE:
651+ lttng_fallthrough;
652+ case LTTNG_KERNEL_ABI_UPROBE:
653+ lttng_fallthrough;
654 case LTTNG_KERNEL_ABI_KRETPROBE:
655 ret = 0;
656 break;
657
658- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
659- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
660+ case LTTNG_KERNEL_ABI_FUNCTION:
661+ lttng_fallthrough;
662+ case LTTNG_KERNEL_ABI_NOOP:
663+ lttng_fallthrough;
664 default:
665 WARN_ON_ONCE(1);
666 }
667@@ -1481,7 +1509,8 @@ int _lttng_event_unregister(struct lttng_kernel_event_recorder *event_recorder)
668 ret = 0;
669 break;
670
671- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
672+ case LTTNG_KERNEL_ABI_FUNCTION:
673+ lttng_fallthrough;
674 default:
675 WARN_ON_ONCE(1);
676 }
677@@ -1512,14 +1541,18 @@ void register_event_notifier(struct lttng_kernel_event_notifier *event_notifier)
678 ret = lttng_syscall_filter_enable_event_notifier(event_notifier);
679 break;
680
681- case LTTNG_KERNEL_ABI_KPROBE: /* Fall-through */
682+ case LTTNG_KERNEL_ABI_KPROBE:
683+ lttng_fallthrough;
684 case LTTNG_KERNEL_ABI_UPROBE:
685 ret = 0;
686 break;
687
688- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
689- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
690- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
691+ case LTTNG_KERNEL_ABI_KRETPROBE:
692+ lttng_fallthrough;
693+ case LTTNG_KERNEL_ABI_FUNCTION:
694+ lttng_fallthrough;
695+ case LTTNG_KERNEL_ABI_NOOP:
696+ lttng_fallthrough;
697 default:
698 WARN_ON_ONCE(1);
699 }
700@@ -1559,9 +1592,12 @@ int _lttng_event_notifier_unregister(
701 ret = lttng_syscall_filter_disable_event_notifier(event_notifier);
702 break;
703
704- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
705- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
706- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
707+ case LTTNG_KERNEL_ABI_KRETPROBE:
708+ lttng_fallthrough;
709+ case LTTNG_KERNEL_ABI_FUNCTION:
710+ lttng_fallthrough;
711+ case LTTNG_KERNEL_ABI_NOOP:
712+ lttng_fallthrough;
713 default:
714 WARN_ON_ONCE(1);
715 }
716@@ -1614,8 +1650,10 @@ void _lttng_event_destroy(struct lttng_kernel_event_common *event)
717 lttng_uprobes_destroy_event_private(event_recorder);
718 break;
719
720- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
721- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
722+ case LTTNG_KERNEL_ABI_FUNCTION:
723+ lttng_fallthrough;
724+ case LTTNG_KERNEL_ABI_NOOP:
725+ lttng_fallthrough;
726 default:
727 WARN_ON_ONCE(1);
728 }
729@@ -1647,9 +1685,12 @@ void _lttng_event_destroy(struct lttng_kernel_event_common *event)
730 lttng_uprobes_destroy_event_notifier_private(event_notifier);
731 break;
732
733- case LTTNG_KERNEL_ABI_KRETPROBE: /* Fall-through */
734- case LTTNG_KERNEL_ABI_FUNCTION: /* Fall-through */
735- case LTTNG_KERNEL_ABI_NOOP: /* Fall-through */
736+ case LTTNG_KERNEL_ABI_KRETPROBE:
737+ lttng_fallthrough;
738+ case LTTNG_KERNEL_ABI_FUNCTION:
739+ lttng_fallthrough;
740+ case LTTNG_KERNEL_ABI_NOOP:
741+ lttng_fallthrough;
742 default:
743 WARN_ON_ONCE(1);
744 }
745@@ -2713,7 +2754,8 @@ void lttng_session_sync_event_enablers(struct lttng_kernel_session *session)
746 int nr_filters = 0;
747
748 switch (event_recorder_priv->parent.instrumentation) {
749- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
750+ case LTTNG_KERNEL_ABI_TRACEPOINT:
751+ lttng_fallthrough;
752 case LTTNG_KERNEL_ABI_SYSCALL:
753 /* Enable events */
754 list_for_each_entry(enabler_ref,
755@@ -2807,7 +2849,8 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
756 int nr_filters = 0, nr_captures = 0;
757
758 switch (event_notifier_priv->parent.instrumentation) {
759- case LTTNG_KERNEL_ABI_TRACEPOINT: /* Fall-through */
760+ case LTTNG_KERNEL_ABI_TRACEPOINT:
761+ lttng_fallthrough;
762 case LTTNG_KERNEL_ABI_SYSCALL:
763 /* Enable event_notifiers */
764 list_for_each_entry(enabler_ref,
765@@ -3877,7 +3920,7 @@ int print_escaped_ctf_string(struct lttng_kernel_session *session, const char *s
766 if (ret)
767 goto error;
768 /* We still print the current char */
769- /* Fallthrough */
770+ lttng_fallthrough;
771 default:
772 ret = lttng_metadata_printf(session, "%c", cur);
773 break;
774diff --git a/src/lttng-string-utils.c b/src/lttng-string-utils.c
775index d9447903..65946193 100644
776--- a/src/lttng-string-utils.c
777+++ b/src/lttng-string-utils.c
778@@ -4,6 +4,7 @@
779 */
780
781 #include <linux/types.h>
782+#include <wrapper/compiler_attributes.h>
783
784 #include <lttng/string-utils.h>
785
786@@ -302,7 +303,7 @@ retry:
787 p = pattern_get_char_at_cb(p_at,
788 pattern_get_char_at_cb_data);
789
790- /* Fall-through. */
791+ lttng_fallthrough;
792 default:
793 /*
794 * Default case which will compare the escaped
795diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c
796index 0fa6a1bf..1d0a5ecb 100644
797--- a/src/probes/lttng-kretprobes.c
798+++ b/src/probes/lttng-kretprobes.c
799@@ -14,6 +14,7 @@
800 #include <lttng/events.h>
801 #include <lttng/events-internal.h>
802 #include <ringbuffer/frontend_types.h>
803+#include <wrapper/compiler_attributes.h>
804 #include <wrapper/vmalloc.h>
805 #include <wrapper/irqflags.h>
806 #include <lttng/tracer.h>
807@@ -61,7 +62,8 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
808 return 0;
809 break;
810 }
811- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: /* Fall-through. */
812+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
813+ lttng_fallthrough;
814 default:
815 WARN_ON_ONCE(1);
816 }
817@@ -90,7 +92,8 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
818 chan->ops->event_commit(&ctx);
819 break;
820 }
821- case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER: /* Fall-through. */
822+ case LTTNG_KERNEL_EVENT_TYPE_NOTIFIER:
823+ lttng_fallthrough;
824 default:
825 WARN_ON_ONCE(1);
826 }
827--
8282.19.1
829