[PATCH v3 08/20] tools/x86/kcpuid: Set function return type to void

Ahmed S. Darwish posted 20 patches 8 months, 4 weeks ago
[PATCH v3 08/20] tools/x86/kcpuid: Set function return type to void
Posted by Ahmed S. Darwish 8 months, 4 weeks ago
parse_line() returns an integer but its caller ignored it. Change the
function signature to return void.

While at it, adjust some of the "Skip line" comments for readability.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
---
 tools/arch/x86/kcpuid/kcpuid.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index 908f0de2d4f0..1db2c8d7cf27 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -277,7 +277,7 @@ struct cpuid_range *setup_cpuid_range(u32 input_eax)
  *	0,    0,  EAX,   31:0, max_basic_leafs,  Max input value for supported subleafs
  *	1,    0,  ECX,      0, sse3,  Streaming SIMD Extensions 3(SSE3)
  */
-static int parse_line(char *line)
+static void parse_line(char *line)
 {
 	char *str;
 	int i;
@@ -307,7 +307,7 @@ static int parse_line(char *line)
 
 	/* Skip comments and NULL line */
 	if (line[0] == '#' || line[0] == '\n')
-		return 0;
+		return;
 
 	strncpy(buffer, line, 511);
 	buffer[511] = 0;
@@ -330,16 +330,15 @@ static int parse_line(char *line)
 	else
 		range = leafs_basic;
 
-	index &= 0x7FFFFFFF;
 	/* Skip line parsing for non-existing indexes */
+	index &= 0x7FFFFFFF;
 	if ((int)index >= range->nr)
-		return -1;
+		return;
 
+	/* Skip line parsing if the index CPUID output is all zero */
 	func = &range->funcs[index];
-
-	/* Return if the index has no valid item on this platform */
 	if (!func->nr)
-		return 0;
+		return;
 
 	/* subleaf */
 	buf = tokens[1];
@@ -352,11 +351,11 @@ static int parse_line(char *line)
 		subleaf_start = strtoul(start, NULL, 0);
 		subleaf_end = min(subleaf_end, (u32)(func->nr - 1));
 		if (subleaf_start > subleaf_end)
-			return 0;
+			return;
 	} else {
 		subleaf_start = subleaf_end;
 		if (subleaf_start > (u32)(func->nr - 1))
-			return 0;
+			return;
 	}
 
 	/* register */
@@ -389,12 +388,11 @@ static int parse_line(char *line)
 		strcpy(bdesc->simp, strtok(tokens[4], " \t"));
 		strcpy(bdesc->detail, tokens[5]);
 	}
-	return 0;
+	return;
 
 err_exit:
 	warnx("Wrong line format:\n"
 	      "\tline[%d]: %s", flines, line);
-	return -1;
 }
 
 /* Parse csv file, and construct the array of all leafs and subleafs */
-- 
2.48.1
[tip: x86/cpu] tools/x86/kcpuid: Set parse_line() return type to void
Posted by tip-bot2 for Ahmed S. Darwish 8 months, 4 weeks ago
The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     8984cea5c4743d7fabf5de9da142cfc5dde1a144
Gitweb:        https://git.kernel.org/tip/8984cea5c4743d7fabf5de9da142cfc5dde1a144
Author:        Ahmed S. Darwish <darwi@linutronix.de>
AuthorDate:    Mon, 24 Mar 2025 15:20:29 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 25 Mar 2025 09:53:45 +01:00

tools/x86/kcpuid: Set parse_line() return type to void

parse_line() returns an integer but its caller ignored it. Change the
function signature to return void.

While at it, adjust some of the "Skip line" comments for readability.

Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20250324142042.29010-9-darwi@linutronix.de
---
 tools/arch/x86/kcpuid/kcpuid.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
index f268c76..4fa768b 100644
--- a/tools/arch/x86/kcpuid/kcpuid.c
+++ b/tools/arch/x86/kcpuid/kcpuid.c
@@ -277,7 +277,7 @@ struct cpuid_range *setup_cpuid_range(u32 input_eax)
  *	0,    0,  EAX,   31:0, max_basic_leafs,  Max input value for supported subleafs
  *	1,    0,  ECX,      0, sse3,  Streaming SIMD Extensions 3(SSE3)
  */
-static int parse_line(char *line)
+static void parse_line(char *line)
 {
 	char *str;
 	int i;
@@ -307,7 +307,7 @@ static int parse_line(char *line)
 
 	/* Skip comments and NULL line */
 	if (line[0] == '#' || line[0] == '\n')
-		return 0;
+		return;
 
 	strncpy(buffer, line, 511);
 	buffer[511] = 0;
@@ -330,16 +330,15 @@ static int parse_line(char *line)
 	else
 		range = leafs_basic;
 
-	index &= 0x7FFFFFFF;
 	/* Skip line parsing for non-existing indexes */
+	index &= 0x7FFFFFFF;
 	if ((int)index >= range->nr)
-		return -1;
+		return;
 
+	/* Skip line parsing if the index CPUID output is all zero */
 	func = &range->funcs[index];
-
-	/* Return if the index has no valid item on this platform */
 	if (!func->nr)
-		return 0;
+		return;
 
 	/* subleaf */
 	buf = tokens[1];
@@ -352,11 +351,11 @@ static int parse_line(char *line)
 		subleaf_start = strtoul(start, NULL, 0);
 		subleaf_end = min(subleaf_end, (u32)(func->nr - 1));
 		if (subleaf_start > subleaf_end)
-			return 0;
+			return;
 	} else {
 		subleaf_start = subleaf_end;
 		if (subleaf_start > (u32)(func->nr - 1))
-			return 0;
+			return;
 	}
 
 	/* register */
@@ -389,12 +388,11 @@ static int parse_line(char *line)
 		strcpy(bdesc->simp, strtok(tokens[4], " \t"));
 		strcpy(bdesc->detail, tokens[5]);
 	}
-	return 0;
+	return;
 
 err_exit:
 	warnx("Wrong line format:\n"
 	      "\tline[%d]: %s", flines, line);
-	return -1;
 }
 
 /* Parse csv file, and construct the array of all leafs and subleafs */