Skip to contentSkip to conversation

x86/alternatives: Fix switch block in apply_reloc()

PATCH In review Pranav Athreya 2 participants 3 messages Jan 22, 2024 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/alternatives: Fix switch block in apply_reloc()

Adhere to Linux kernel coding style

Reported by checkpatch:

ERROR: trailing statements should be on next line
+ case 1: apply_reloc_n(8, ptr, diff); break;

ERROR: trailing statements should be on next line
+ case 2: apply_reloc_n(16, ptr, diff); break;

ERROR: trailing statements should be on next line
+ case 4: apply_reloc_n(32, ptr, diff); break;

ERROR: trailing statements should be on next line
+ default: BUG();

---
 arch/x86/kernel/alternative.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
arch/x86/kernel/alternative.c +11 -4
index ee0f681ae107..340cb5724d8f 100644
@@ -297,10 +297,17 @@ static __always_inline
 void apply_reloc(int n, void *ptr, uintptr_t diff)
 {
 	switch (n) {
-	case 1: apply_reloc_n(8, ptr, diff); break;
-	case 2: apply_reloc_n(16, ptr, diff); break;
-	case 4: apply_reloc_n(32, ptr, diff); break;
-	default: BUG();
+	case 1:
+		apply_reloc_n(8, ptr, diff);
+	       	break;
+	case 2: 
+		apply_reloc_n(16, ptr, diff);
+	       	break;
+	case 4: 
+		apply_reloc_n(32, ptr, diff);
+	       	break;
+	default:
+	       	BUG();
 	}
 }
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw

arch/x86/kernel/alternative.c static __always_inline · line 303

Quoted 4 lines · Pranav Athreya
arch/x86/kernel/alternative.c +0 -4
-	case 1: apply_reloc_n(8, ptr, diff); break;
-	case 2: apply_reloc_n(16, ptr, diff); break;
-	case 4: apply_reloc_n(32, ptr, diff); break;
-	default: BUG();

It is more compact and faster readable this way. Do not always take what checkpatch tells you to the letter.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#2 lore raw
Quoted 2 lines · Borislav Petkov

It is more compact and faster readable this way. Do not always take what checkpatch tells you to the letter.

Understood. Thank you for the feedback, Boris.

Regards,
Pranav