Skip to contentSkip to conversation

ring-buffer: Fix fall-through warning for Clang

PATCH In review Gustavo A. R. Silva 3 participants 3 messages May 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ring-buffer: Fix fall-through warning for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a fall-through warning by replacing a /* fall through */ comment with the new pseudo-keyword macro fallthrough;

Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings, so in order to globally enable -Wimplicit-fallthrough for Clang, these comments need to be replaced with fallthrough; in the whole codebase.

---
JFYI: We had thousands of these sorts of warnings and now we are down
to just 25 in linux-next. This is one of those last remaining warnings.

 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ring_buffer.c +1 -1
index 2c0ee6484990..d1463eac11a3 100644
@@ -3391,7 +3391,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,
 		case RINGBUF_TYPE_PADDING:
 			if (event->time_delta == 1)
 				break;
-			/* fall through */
+			fallthrough;
 		case RINGBUF_TYPE_DATA:
 			ts += event->time_delta;
 			break;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 9 lines · On Fri, 28 May 2021 14:59:42 -0500 "Gustavo A. R. Silva"…

In preparation to enable -Wimplicit-fallthrough for Clang, fix a fall-through warning by replacing a /* fall through */ comment with the new pseudo-keyword macro fallthrough;

Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings, so in order to globally enable -Wimplicit-fallthrough for Clang, these comments need to be replaced with fallthrough; in the whole codebase.

Quoted 6 lines

---
JFYI: We had thousands of these sorts of warnings and now we are down
to just 25 in linux-next. This is one of those last remaining warnings.

And I have it fixed locally already.

https://lore.kernel.org/lkml/[email protected]/

I've just been on vacation and haven't pushed it to next yet. It's still in the "to be tested" queue.

-- Steve

Quoted 17 lines
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ring_buffer.c +1 -1
index 2c0ee6484990..d1463eac11a3 100644
@@ -3391,7 +3391,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer,
 		case RINGBUF_TYPE_PADDING:
 			if (event->time_delta == 1)
 				break;
-			/* fall through */
+			fallthrough;
 		case RINGBUF_TYPE_DATA:
 			ts += event->time_delta;
 			break;
#2 lore raw
Quoted 19 lines · Steven Rostedt
Quoted 9 lines · On Fri, 28 May 2021 14:59:42 -0500 "Gustavo A. R. Silva"…

In preparation to enable -Wimplicit-fallthrough for Clang, fix a fall-through warning by replacing a /* fall through */ comment with the new pseudo-keyword macro fallthrough;

Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings, so in order to globally enable -Wimplicit-fallthrough for Clang, these comments need to be replaced with fallthrough; in the whole codebase.

Quoted 6 lines

---
JFYI: We had thousands of these sorts of warnings and now we are down
to just 25 in linux-next. This is one of those last remaining warnings.

Quoted 6 lines

And I have it fixed locally already.

https://lore.kernel.org/lkml/[email protected]/

I've just been on vacation and haven't pushed it to next yet. It's still in the "to be tested" queue.

Awesome! :)

Thanks, Steven.
--
Gustavo