Skip to contentSkip to conversation

acpi: sysfs: Fixed a control flow style issue

PATCH In review Clayton Casciato 2 participants 3 messages Jun 12, 2021 – Jun 16, 2021 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: sysfs: Fixed a control flow style issue

Fixed coding style issue.

---
 drivers/acpi/sysfs.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/acpi/sysfs.c +9 -9
index d6626aba4a6a..0e685ca8f78f 100644
@@ -254,15 +254,15 @@ static int param_get_trace_state(char *buffer, const struct kernel_param *kp)
 {
 	if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED))
 		return sprintf(buffer, "disable\n");
-	else {
-		if (acpi_gbl_trace_method_name) {
-			if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
-				return sprintf(buffer, "method-once\n");
-			else
-				return sprintf(buffer, "method\n");
-		} else
-			return sprintf(buffer, "enable\n");
-	}
+
+	if (acpi_gbl_trace_method_name) {
+		if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
+			return sprintf(buffer, "method-once\n");
+		else
+			return sprintf(buffer, "method\n");
+	} else
+		return sprintf(buffer, "enable\n");
+
 	return 0;
 }
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 2 lines · Clayton Casciato

Fixed coding style issue.

I'm not really sure what issue you are fixing here.

Is it the redundant braces around the nested if () statement?

If so, the flow before and after the patch is different. Is this intentional?

Quoted 37 lines
---
 drivers/acpi/sysfs.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/acpi/sysfs.c +9 -10
index d6626aba4a6a..0e685ca8f78f 100644
@@ -254,15 +254,15 @@ static int param_get_trace_state(char *buffer, const struct kernel_param *kp)
 {
        if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED))
                return sprintf(buffer, "disable\n");
-       else {
-               if (acpi_gbl_trace_method_name) {
-                       if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
-                               return sprintf(buffer, "method-once\n");
-                       else
-                               return sprintf(buffer, "method\n");
-               } else
-                       return sprintf(buffer, "enable\n");
-       }
+
+       if (acpi_gbl_trace_method_name) {
+               if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
+                       return sprintf(buffer, "method-once\n");
+               else
+                       return sprintf(buffer, "method\n");
+       } else
+               return sprintf(buffer, "enable\n");
+
        return 0;
 }
 
--

2.31.1

#2 lore raw
Quoted 7 lines · Rafael J. Wysocki
Quoted 2 lines · Clayton Casciato

Fixed coding style issue.

I'm not really sure what issue you are fixing here.

Checkpatch warns that "else is not generally useful after a break or return".

Quoted 2 lines

Is it the redundant braces around the nested if () statement?

The patch only removes the else clause.

Quoted 2 lines

If so, the flow before and after the patch is different. Is this intentional?

Yes. The patch improves readability by removing the outermost context, reducing the nested conditional complexity.

Thank you for your consideration!

Quoted 37 lines
Quoted 37 lines
---
 drivers/acpi/sysfs.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/acpi/sysfs.c +9 -10
index d6626aba4a6a..0e685ca8f78f 100644
@@ -254,15 +254,15 @@ static int param_get_trace_state(char *buffer, const struct kernel_param *kp)
 {
        if (!(acpi_gbl_trace_flags & ACPI_TRACE_ENABLED))
                return sprintf(buffer, "disable\n");
-       else {
-               if (acpi_gbl_trace_method_name) {
-                       if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
-                               return sprintf(buffer, "method-once\n");
-                       else
-                               return sprintf(buffer, "method\n");
-               } else
-                       return sprintf(buffer, "enable\n");
-       }
+
+       if (acpi_gbl_trace_method_name) {
+               if (acpi_gbl_trace_flags & ACPI_TRACE_ONESHOT)
+                       return sprintf(buffer, "method-once\n");
+               else
+                       return sprintf(buffer, "method\n");
+       } else
+               return sprintf(buffer, "enable\n");
+
        return 0;
 }
 
--

2.31.1