2015-11-05 15:22:54

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH] ACPICA: Delete unnecessary checks before the function call "acpi_ut_strupr"

From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 16:12:32 +0100

The acpi_ut_strupr() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/acpi/acpica/dbcmds.c | 9 ++-------
drivers/acpi/acpica/dbinput.c | 5 +----
2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/acpica/dbcmds.c b/drivers/acpi/acpica/dbcmds.c
index 30414b3..7dcc95a 100644
--- a/drivers/acpi/acpica/dbcmds.c
+++ b/drivers/acpi/acpica/dbcmds.c
@@ -1131,13 +1131,8 @@ void acpi_db_trace(char *enable_arg, char *method_arg, char *once_arg)
u32 debug_layer = 0;
u32 flags = 0;

- if (enable_arg) {
- acpi_ut_strupr(enable_arg);
- }
-
- if (once_arg) {
- acpi_ut_strupr(once_arg);
- }
+ acpi_ut_strupr(enable_arg);
+ acpi_ut_strupr(once_arg);

if (method_arg) {
if (acpi_db_trace_method_name) {
diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
index 0480254..aa1dcee 100644
--- a/drivers/acpi/acpica/dbinput.c
+++ b/drivers/acpi/acpica/dbinput.c
@@ -622,10 +622,7 @@ static u32 acpi_db_get_line(char *input_buffer)
}

/* Uppercase the actual command */
-
- if (acpi_gbl_db_args[0]) {
- acpi_ut_strupr(acpi_gbl_db_args[0]);
- }
+ acpi_ut_strupr(acpi_gbl_db_args[0]);

count = i;
if (count) {
--
2.6.2


2015-11-05 16:28:50

by Moore, Robert

[permalink] [raw]
Subject: RE: [PATCH] ACPICA: Delete unnecessary checks before the function call "acpi_ut_strupr"

Agreed, we will implement your suggestions in the ACPICA code (which is in a different format than the Linux version).


> -----Original Message-----
> From: SF Markus Elfring [mailto:[email protected]]
> Sent: Thursday, November 05, 2015 7:23 AM
> To: Len Brown; Zheng, Lv; Wysocki, Rafael J; Moore, Robert; linux-
> [email protected]; [email protected]
> Cc: LKML; [email protected]; Julia Lawall
> Subject: [PATCH] ACPICA: Delete unnecessary checks before the function
> call "acpi_ut_strupr"
>
> From: Markus Elfring <[email protected]>
> Date: Thu, 5 Nov 2015 16:12:32 +0100
>
> The acpi_ut_strupr() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> drivers/acpi/acpica/dbcmds.c | 9 ++-------
> drivers/acpi/acpica/dbinput.c | 5 +----
> 2 files changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/acpica/dbcmds.c b/drivers/acpi/acpica/dbcmds.c
> index 30414b3..7dcc95a 100644
> --- a/drivers/acpi/acpica/dbcmds.c
> +++ b/drivers/acpi/acpica/dbcmds.c
> @@ -1131,13 +1131,8 @@ void acpi_db_trace(char *enable_arg, char
> *method_arg, char *once_arg)
> u32 debug_layer = 0;
> u32 flags = 0;
>
> - if (enable_arg) {
> - acpi_ut_strupr(enable_arg);
> - }
> -
> - if (once_arg) {
> - acpi_ut_strupr(once_arg);
> - }
> + acpi_ut_strupr(enable_arg);
> + acpi_ut_strupr(once_arg);
>
> if (method_arg) {
> if (acpi_db_trace_method_name) {
> diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c
> index 0480254..aa1dcee 100644
> --- a/drivers/acpi/acpica/dbinput.c
> +++ b/drivers/acpi/acpica/dbinput.c
> @@ -622,10 +622,7 @@ static u32 acpi_db_get_line(char *input_buffer)
> }
>
> /* Uppercase the actual command */
> -
> - if (acpi_gbl_db_args[0]) {
> - acpi_ut_strupr(acpi_gbl_db_args[0]);
> - }
> + acpi_ut_strupr(acpi_gbl_db_args[0]);
>
> count = i;
> if (count) {
> --
> 2.6.2

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?