Commit b30bb89f authored by Julia Lawall's avatar Julia Lawall Committed by Matthew Garrett

fujitsu-laptop: fix error return code

These functions mix the use of result and error.  In acpi_fujitsu_add,
result does not seem useful; it would seem reasonable to propagate the
return value of acpi_bus_update_power in an error case.  On the other hand,
in the case of acpi_fujitsu_hotkey_add, there is an initialization of
result that can lead to what looks like a failure case, but that does not
abort the function.  The variable result is kept for this case.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
parent 97f440c2
...@@ -633,7 +633,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = { ...@@ -633,7 +633,6 @@ static struct dmi_system_id fujitsu_dmi_table[] = {
static int acpi_fujitsu_add(struct acpi_device *device) static int acpi_fujitsu_add(struct acpi_device *device)
{ {
int result = 0;
int state = 0; int state = 0;
struct input_dev *input; struct input_dev *input;
int error; int error;
...@@ -669,8 +668,8 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -669,8 +668,8 @@ static int acpi_fujitsu_add(struct acpi_device *device)
if (error) if (error)
goto err_free_input_dev; goto err_free_input_dev;
result = acpi_bus_update_power(fujitsu->acpi_handle, &state); error = acpi_bus_update_power(fujitsu->acpi_handle, &state);
if (result) { if (error) {
pr_err("Error reading power state\n"); pr_err("Error reading power state\n");
goto err_unregister_input_dev; goto err_unregister_input_dev;
} }
...@@ -700,7 +699,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -700,7 +699,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
get_lcd_level(); get_lcd_level();
return result; return 0;
err_unregister_input_dev: err_unregister_input_dev:
input_unregister_device(input); input_unregister_device(input);
...@@ -708,7 +707,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -708,7 +707,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
err_free_input_dev: err_free_input_dev:
input_free_device(input); input_free_device(input);
err_stop: err_stop:
return result; return error;
} }
static int acpi_fujitsu_remove(struct acpi_device *device) static int acpi_fujitsu_remove(struct acpi_device *device)
...@@ -831,8 +830,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -831,8 +830,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
if (error) if (error)
goto err_free_input_dev; goto err_free_input_dev;
result = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state); error = acpi_bus_update_power(fujitsu_hotkey->acpi_handle, &state);
if (result) { if (error) {
pr_err("Error reading power state\n"); pr_err("Error reading power state\n");
goto err_unregister_input_dev; goto err_unregister_input_dev;
} }
...@@ -907,7 +906,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -907,7 +906,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
err_free_fifo: err_free_fifo:
kfifo_free(&fujitsu_hotkey->fifo); kfifo_free(&fujitsu_hotkey->fifo);
err_stop: err_stop:
return result; return error;
} }
static int acpi_fujitsu_hotkey_remove(struct acpi_device *device) static int acpi_fujitsu_hotkey_remove(struct acpi_device *device)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment