Skip to contentSkip to conversation

ring-buffer: simplify if-if to if-else

PATCH Superseded Wan Jiabing 3 participants 3 messages Apr 24, 2022 – Apr 25, 2022

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ring-buffer: simplify if-if to if-else

Use if and else instead of if(A) and if (!A).

---
 kernel/trace/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ring_buffer.c +1 -1
index 05dfc7a12d3d..0fa21bd1a1e9 100644
@@ -6014,7 +6014,7 @@ static __init int test_ringbuffer(void)
 		if (total_lost)
 			pr_info(" With dropped events, record len and size may not match\n"
 				" alloced and written from above\n");
-		if (!total_lost) {
+		else {
 			if (RB_WARN_ON(buffer, total_len != total_alloc ||
 				       total_size != total_written))
 				break;
Signature · 1 line
2.35.1
#1 lore raw
Quoted 1 line · Wan Jiabing

Use if and else instead of if(A) and if (!A).

[]

kernel/trace/ring_buffer.c

Quoted 1 line
kernel/trace/ring_buffer.c +0 -0

[]

kernel/trace/ring_buffer.c static __init int test_ringbuffer(void) · line 6017

Quoted 6 lines
kernel/trace/ring_buffer.c +1 -1
@@ -6014,7 +6014,7 @@ static __init int test_ringbuffer(void)
 		if (total_lost)
 			pr_info(" With dropped events, record len and size may not match\n"
 				" alloced and written from above\n");
-		if (!total_lost) {
+		else {

please run your proposed patches through checkpatch.

(add braces to the if block)

additionally:

the pr_info on two lines seems pointless and it's probably nicer just written on a single line.

			pr_info(" With dropped events, recorded len and size may not match alloced and written from above\n");
Quoted 3 lines
kernel/trace/ring_buffer.c +0 -0
 			if (RB_WARN_ON(buffer, total_len != total_alloc ||
 				       total_size != total_written))
 				break;
maintainer
#2 lore raw
Quoted 4 lines · On Sun, 24 Apr 2022 09:12:45 -0700 Joe Perches <[email protected]> wrote:

the pr_info on two lines seems pointless and it's probably nicer just written on a single line.

			pr_info(" With dropped events, recorded len and size may not match alloced and written from above\n");

Which makes it 86 characters long, and this test is run on my machine that has a 80 character console.

Please keep the original line breakage.

-- Steve