ACPI: Convert non-returned local variable to boolean when relevant
Subsystems (3)
PATCH 1/4 ACPI: Convert non-returned local variable to boolean when relevant
This patch was produced using Coccinelle. A simplified version of the semantic patch is:
@r exists@
identifier f;
local idexpression u8 x;
identifier xname;
@@
f(...) {
...when any
(
x@xname = 1;
|
x@xname = 0;
)
...when any
}
@bad exists@
identifier r.f;
local idexpression u8 r.x
expression e1 != {0, 1}, e2;
@@
f(...) {
...when any
(
x = e1;
|
x + e2
)
...when any
}
@depends on !bad@
identifier r.f;
local idexpression u8 r.x;
identifier r.xname;
@@
f(...) {
...
++ bool xname;
- int xname;
<...
(
x =
- 1
+ true
|
x =
- -1
+ false
)
...>
}
Signed-off-by Quentin Lambert <[email protected]>
--- drivers/acpi/acpica/utstring.c | 10 +++++----- drivers/acpi/dock.c | 4 ++-- drivers/acpi/pci_link.c | 4 ++-- drivers/acpi/scan.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/acpi/acpica/utstring.c +5 -5
@@ -178,8 +178,8 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)u32 to_integer_op = (base ==ACPI_ANY_BASE );u32 mode32 = (acpi_gbl_integer_byte_width ==4 );u8 valid_digits =0 ; -u8 sign_of0x =0 ; -u8 term =0 ; +bool sign_of0x = false; +bool term = false;ACPI_FUNCTION_TRACE_STR (ut_stroul64, string);
@@ -212,7 +212,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)* We need to determine if it is decimal or hexadecimal. */ if ((*string =='0' ) && (ACPI_TOLOWER (*(string +1 )) =='x' )) { - sign_of0x =1 ; + sign_of0x = true; base =16 ;/* Skip over the leading '0x' */
@@ -250,7 +250,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)/* Digit is out of range; possible in to_integer case only */ - term =1 ; + term = true; }else { this_digit = (u8 )ACPI_TOUPPER (*string);if (ACPI_IS_XDIGIT ((char )this_digit)) {
@@ -259,7 +259,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer) this_digit = this_digit -'A' +10 ; }else { - term =1 ; + term = true; } }
drivers/acpi/dock.c +2 -2
@@ -445,7 +445,7 @@ int dock_notify(struct acpi_device *adev, u32 event) {acpi_handle handle = adev->handle;struct dock_station *ds =find_dock_station (handle); -int surprise_removal =0 ; +bool surprise_removal = false;if (!ds)return -ENODEV ;
@@ -488,7 +488,7 @@ int dock_notify(struct acpi_device *adev, u32 event)if (dock_present (ds) ||dock_in_progress (ds))break ;/* This is a surprise removal */ - surprise_removal =1 ; + surprise_removal = true; event =ACPI_NOTIFY_EJECT_REQUEST ;/* Fall back */ case ACPI_NOTIFY_EJECT_REQUEST :
drivers/acpi/pci_link.c +2 -2
@@ -693,7 +693,7 @@ static int acpi_pci_link_add(struct acpi_device *device,int result;struct acpi_pci_link *link;int i; -int found =0 ; +bool found = false; link =kzalloc (sizeof (struct acpi_pci_link ),GFP_KERNEL );if (!link)
@@ -717,7 +717,7 @@ static int acpi_pci_link_add(struct acpi_device *device,for (i =0 ; i < link->irq.possible_count; i++) {if (link->irq.active == link->irq.possible[i]) {printk (KERN_CONT " *%d" , link->irq.possible[i]); - found =1 ; + found = true; }else printk (KERN_CONT " %d" , link->irq.possible[i]); }
drivers/acpi/scan.c +2 -2
@@ -1306,7 +1306,7 @@ int acpi_device_add(struct acpi_device *device, {int result;struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; -int found =0 ; +bool found = false;if (device->handle) {acpi_status status;
@@ -1348,7 +1348,7 @@ int acpi_device_add(struct acpi_device *device,if (!strcmp (acpi_device_bus_id->bus_id,acpi_device_hid (device))) { acpi_device_bus_id->instance_no++; - found =1 ; + found = true;kfree (new_bus_id);break ; }
Signature · 1 line
1.9.1