lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 13 Jul 2010 09:25:08 -0700
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	Axel Lin <axel.lin@...il.com>
Cc:	linux-kernel <linux-kernel@...r.kernel.org>,
	Lin Ming <ming.m.lin@...el.com>, linux-input@...r.kernel.org
Subject: Re: [PATCH] atlas_btns: fix mixing acpi_status and int for return
 value

On Tue, Jul 13, 2010 at 05:31:15PM +0800, Axel Lin wrote:
> To improve readability, this patch fixes mixing acpi_status
> and int for return value.
> 
> Signed-off-by: Axel Lin <axel.lin@...il.com>
> ---
>  drivers/input/misc/atlas_btns.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
> index 7d53608..ea14800 100644
> --- a/drivers/input/misc/atlas_btns.c
> +++ b/drivers/input/misc/atlas_btns.c
> @@ -60,12 +60,12 @@ static acpi_status acpi_atlas_button_handler(u32 function,
>  		input_report_key(input_dev, atlas_keymap[code], key_down);
>  		input_sync(input_dev);
>  
> -		status = 0;
> +		status = AE_OK;
>  	} else {
>  		printk(KERN_WARNING "atlas: shrugged on unexpected function"
>  			":function=%x,address=%lx,value=%x\n",
>  			function, (unsigned long)address, (u32)*value);
> -		status = -EINVAL;
> +		status = AE_BAD_PARAMETER;
>  	}
>  
>  	return status;
> @@ -114,26 +114,27 @@ static int atlas_acpi_button_add(struct acpi_device *device)
>  	if (ACPI_FAILURE(status)) {
>  		printk(KERN_ERR "Atlas: Error installing addr spc handler\n");
>  		input_unregister_device(input_dev);
> -		status = -EINVAL;
> +		err = -EINVAL;
>  	}
>  
> -	return status;
> +	return err;
>  }
>  
>  static int atlas_acpi_button_remove(struct acpi_device *device, int type)
>  {
>  	acpi_status status;
> +	int err = 0;
>  
>  	status = acpi_remove_address_space_handler(device->handle,
>  				0x81, &acpi_atlas_button_handler);
>  	if (ACPI_FAILURE(status)) {
>  		printk(KERN_ERR "Atlas: Error removing addr spc handler\n");
> -		status = -EINVAL;
> +		err = -EINVAL;
>  	}
>  
>  	input_unregister_device(input_dev);
>  
> -	return status;
> +	return err;

We should not report any errors since operation is irreversible, just
log them. I believe typing remove methods as returning int instead of
void was a mistake.

I'll fix it up and apply both patches, thanks Axel.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ