Skip to contentSkip to conversation

x86: Coding style fixes to arch/x86/kernel/bios_uv.c

PATCH In review Paolo Ciarrocchi 5 participants 8 messages Aug 2, 2008 – Aug 16, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 2/5 x86: Coding style fixes to arch/x86/kernel/bios_uv.c

Before:
total: 5 errors, 0 warnings, 48 lines checked

After:
total: 0 errors, 0 warnings, 58 lines checked

paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/bios_uv.o.*
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.after
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.before
---
 arch/x86/kernel/bios_uv.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/kernel/bios_uv.c +15 -5
index c639bd5..100e759 100644
@@ -25,11 +25,21 @@ x86_bios_strerror(long status)
 {
 	const char *str;
 	switch (status) {
-	case  0: str = "Call completed without error"; break;
-	case -1: str = "Not implemented"; break;
-	case -2: str = "Invalid argument"; break;
-	case -3: str = "Call completed with error"; break;
-	default: str = "Unknown BIOS status code"; break;
+	case  0:
+		str = "Call completed without error";
+		break;
+	case -1:
+		str = "Not implemented";
+		break;
+	case -2:
+		str = "Invalid argument";
+		break;
+	case -3:
+		str = "Call completed with error";
+		break;
+	default:
+		str = "Unknown BIOS status code";
+		break;
 	}
 	return str;
 }
Signature · 1 line
1.5.6.rc1.21.g03300
#1 lore raw
Quoted 22 lines · Paolo Ciarrocchi
arch/x86/kernel/bios_uv.c +8 -5
index c639bd5..100e759 100644
@@ -25,11 +25,21 @@ x86_bios_strerror(long status)
 {
 	const char *str;
 	switch (status) {
-	case  0: str = "Call completed without error"; break;
-	case -1: str = "Not implemented"; break;
-	case -2: str = "Invalid argument"; break;
-	case -3: str = "Call completed with error"; break;
-	default: str = "Unknown BIOS status code"; break;
+	case  0:
+		str = "Call completed without error";
+		break;
+	case -1:
+		str = "Not implemented";
+		break;
+	case -2:
+		str = "Invalid argument";

arch/x86/kernel/bios_uv.c x86_bios_strerror(long status) · line 45

Quoted 10 lines
arch/x86/kernel/bios_uv.c +7 -0
+		break;
+	case -3:
+		str = "Call completed with error";
+		break;
+	default:
+		str = "Unknown BIOS status code";
+		break;
 	}
 	return str;
 }

This should be an array in the first place...

-hpa

#2 lore raw
Quoted 27 lines · H. Peter Anvin
Quoted 26 lines · Paolo Ciarrocchi
arch/x86/kernel/bios_uv.c +12 -5
index c639bd5..100e759 100644
@@ -25,11 +25,21 @@ x86_bios_strerror(long status)
 {
     const char *str;
     switch (status) {
-    case  0: str = "Call completed without error"; break;
-    case -1: str = "Not implemented"; break;
-    case -2: str = "Invalid argument"; break;
-    case -3: str = "Call completed with error"; break;
-    default: str = "Unknown BIOS status code"; break;
+    case  0:
+        str = "Call completed without error";
+        break;
+    case -1:
+        str = "Not implemented";
+        break;
+    case -2:
+        str = "Invalid argument";
+        break;
+    case -3:
+        str = "Call completed with error";
+        break;
Quoted 8 lines

arch/x86/kernel/bios_uv.c x86_bios_strerror(long status) · line 45

Quoted 6 lines
arch/x86/kernel/bios_uv.c +3 -0
+    default:
+        str = "Unknown BIOS status code";
+        break;
     }
     return str;
 }

This should be an array in the first place...

Besides, by following CodingStyle to the letter, it arguably breaks rather than fixes coding style. The former code was easy enough to read.

Signature · 3 lines
Stefan Richter
-=====-==--- =--- ---==
http://arcgraph.de/sr/
#3 lore raw
Quoted 26 lines · Stefan Richter
Quoted 26 lines
Quoted 25 lines
     const char *str;
     switch (status) {
arch/x86/kernel/bios_uv.c +15 -5
-    case  0: str = "Call completed without error"; break;
-    case -1: str = "Not implemented"; break;
-    case -2: str = "Invalid argument"; break;
-    case -3: str = "Call completed with error"; break;
-    default: str = "Unknown BIOS status code"; break;
+    case  0:
+        str = "Call completed without error";
+        break;
+    case -1:
+        str = "Not implemented";
+        break;
+    case -2:
+        str = "Invalid argument";
+        break;
+    case -3:
+        str = "Call completed with error";
+        break;
+    default:
+        str = "Unknown BIOS status code";
+        break;
     }
     return str;
 }
Quoted 5 lines
Quoted 1 line

This should be an array in the first place...

Besides, by following CodingStyle to the letter, it arguably breaks rather than fixes coding style. The former code was easy enough to read.

Right. The latter is much worse. That's why nobody can trust CodingStyle and/or checkpatch automatically. It's only sane mode of operation is as a help tool for authors and maintainers, to quickly locate _potential_ problems.

Signature · 1 line
Krzysztof Halasa
#4 lore raw

On Sun, Aug 3, 2008 at 1:54 PM, Krzysztof Halasa <[email protected]> wrote:
[...]

Quoted 4 lines

Right. The latter is much worse. That's why nobody can trust CodingStyle and/or checkpatch automatically. It's only sane mode of operation is as a help tool for authors and maintainers, to quickly locate _potential_ problems.

_much worse_? Wow, I thought the opposite.
Anyway, that's just a coding style patch, feel free to simply not apply it as it's really a matter of personal taste but be sure that I'm not blindly changing the code
accordingly to checkpatch. That might be almost true when I started doing this kind of patches months
ago but it's definitely not true anymore.

Thanks.

regards,

Signature · 2 lines
Paolo
http://paolo.ciarrocchi.googlepages.com/
#5 lore raw
Quoted 9 lines · Paolo Ciarrocchi

_much worse_? Wow, I thought the opposite.
Anyway, that's just a coding style patch, feel free to simply not apply it as it's really a matter of personal taste but be sure that I'm not blindly changing the code
accordingly to checkpatch. That might be almost true when I started doing this kind of patches months
ago but it's definitely not true anymore.

In this case, the real problem is that the original code used a switch statement where it really should have used a table.

-hpa

#6 lore raw
In reply to Paolo Ciarrocchi
Quoted 33 lines · Paolo Ciarrocchi

Before:
total: 5 errors, 0 warnings, 48 lines checked

After:
total: 0 errors, 0 warnings, 58 lines checked

paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/bios_uv.o.*
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.after
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.before
---
 arch/x86/kernel/bios_uv.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
arch/x86/kernel/bios_uv.c +5 -5
index c639bd5..100e759 100644
@@ -25,11 +25,21 @@ x86_bios_strerror(long status)
 {
 	const char *str;
 	switch (status) {
-	case  0: str = "Call completed without error"; break;
-	case -1: str = "Not implemented"; break;
-	case -2: str = "Invalid argument"; break;
-	case -3: str = "Call completed with error"; break;
-	default: str = "Unknown BIOS status code"; break;
+	case  0:
+		str = "Call completed without error";
+		break;
+	case -1:
+		str = "Not implemented";

arch/x86/kernel/bios_uv.c x86_bios_strerror(long status) · line 42

Quoted 10 lines
arch/x86/kernel/bios_uv.c +10 -0
+		break;
+	case -2:
+		str = "Invalid argument";
+		break;
+	case -3:
+		str = "Call completed with error";
+		break;
+	default:
+		str = "Unknown BIOS status code";
+		break;

hm - i changed your patch to the one below, to align the break's vertically, which makes the original variant a lot more readable (and even more readable than the new one). Checkpatch still complains about it but that's OK, there are always exceptions.

Ingo

------------------->
Subject: x86: coding style fixes to arch/x86/kernel/bios_uv.c
From: Paolo Ciarrocchi <[email protected]>
Date: Sat, 2 Aug 2008 21:24:06 +0200

paolo@paolo-desktop:~/linux.trees.git$ md5sum /tmp/bios_uv.o.*
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.after
9afe794594831166704744184e192ed8  /tmp/bios_uv.o.before
---
 arch/x86/kernel/bios_uv.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/bios_uv.c +5 -5
Index: tip/arch/x86/kernel/bios_uv.c
===================================================================
@@ -25,11 +25,11 @@ x86_bios_strerror(long status)
 {
 	const char *str;
 	switch (status) {
-	case  0: str = "Call completed without error"; break;
-	case -1: str = "Not implemented"; break;
-	case -2: str = "Invalid argument"; break;
-	case -3: str = "Call completed with error"; break;
-	default: str = "Unknown BIOS status code"; break;
+	case  0: str = "Call completed without error";	break;
+	case -1: str = "Not implemented";		break;
+	case -2: str = "Invalid argument";		break;
+	case -3: str = "Call completed with error";	break;
+	default: str = "Unknown BIOS status code";	break;
 	}
 	return str;
 }
#7 lore raw
Quoted 5 lines · Ingo Molnar

hm - i changed your patch to the one below, to align the break's vertically, which makes the original variant a lot more readable (and even more readable than the new one). Checkpatch still complains about it but that's OK, there are always exceptions.

thank you Ingo.

ciao,

Signature · 2 lines
Paolo
http://paolo.ciarrocchi.googlepages.com/