Skip to contentSkip to conversation

net: fjes: Refactor a string comparison in is_extended_socket_device()

PATCH In review Markus Elfring 2 participants 2 messages Sep 20, 2024 – Sep 22, 2024

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

PATCH 1/1 net: fjes: Refactor a string comparison in is_extended_socket_device()

From: Markus Elfring <[email protected]>
Date: Fri, 20 Sep 2024 13:56:44 +0200

Assign the return value from a strncmp() call to a local variable so that an if statement can be omitted accordingly.

This issue was detected by using the Coccinelle software.

---
 drivers/net/fjes/fjes_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/fjes/fjes_main.c +2 -6
index fad5b6564464..1fae30798899 100644
@@ -54,13 +54,9 @@ static bool is_extended_socket_device(struct acpi_device *device)
 				 str_buf, sizeof(str_buf) - 1);
 	str_buf[result] = 0;
 
-	if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) {
-		kfree(buffer.pointer);
-		return false;
-	}
+	result = strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL));
 	kfree(buffer.pointer);
-
-	return true;
+	return result == 0;
 }
 
 static int acpi_check_extended_socket_status(struct acpi_device *device)

--
2.46.0

reviewer
#1 lore raw
Quoted 9 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 20 Sep 2024 13:56:44 +0200

Assign the return value from a strncmp() call to a local variable so that an if statement can be omitted accordingly.

This issue was detected by using the Coccinelle software.

Hi Markus,

This is an old driver, that doesn't appear to have been under active development for quite some time. And I don't think that clean-ups of this nature are worth the risk of regressions they might introduce.

If we can see bugs, let's fix them.
Else, let's leave it be.

Signature · 1 line
pw-bot: rejected