Re: [PATCH 2/3] staging: speakup: use native error codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 27, 2013 at 05:44:56PM +0200, Andy Shevchenko wrote:
> The mapping as follows:
> 	E_RANGE		-> ERANGE
> 	E_UNDEF		-> ENODATA
> 	E_TOOLONG	-> E2BIG
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/staging/speakup/kobjects.c    |  4 ++--
>  drivers/staging/speakup/speakup.h     |  3 ---
>  drivers/staging/speakup/varhandlers.c | 12 ++++++------
>  3 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index d0f660b..04bf8e8 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -619,7 +619,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
>  			len = E_SET;
>  		value = simple_strtol(cp, NULL, 10);
>  		ret = spk_set_num_var(value, param, len);
> -		if (ret == E_RANGE) {
> +		if (ret == -ERANGE) {
>  			var_data = param->data;
>  			pr_warn("value for %s out of range, expect %d to %d\n",
>  				attr->attr.name,
> @@ -637,7 +637,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
>  		cp = (char *) buf;
>  		cp[len] = '\0';
>  		ret = spk_set_string_var(buf, param, len);
> -		if (ret == E_TOOLONG)
> +		if (ret == -E2BIG)
>  			pr_warn("value too long for %s\n",
>  					attr->attr.name);
>  		break;
> diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h
> index 1e5691c..4c67c73 100644
> --- a/drivers/staging/speakup/speakup.h
> +++ b/drivers/staging/speakup/speakup.h
> @@ -45,9 +45,6 @@
>  #define IS_TYPE(x, type) ((spk_chartab[((u_char)x)]&type) == type)
>  
>  #define SET_DEFAULT -4
> -#define E_RANGE -3
> -#define E_TOOLONG -2
> -#define E_UNDEF -1
>  
>  extern int speakup_thread(void *data);
>  extern void spk_reset_default_chars(void);
> diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
> index 0a237da..fb479a5 100644
> --- a/drivers/staging/speakup/varhandlers.c
> +++ b/drivers/staging/speakup/varhandlers.c
> @@ -249,9 +249,9 @@ int spk_set_string_var(const char *page, struct st_var_header *var, int len)
>  	int ret = 0;
>  	struct var_t *var_data = var->data;
>  	if (var_data == NULL)
> -		return E_UNDEF;
> +		return -ENODATA;
>  	if (len > MAXVARLEN)
> -		return -E_TOOLONG;
> +		return -E2BIG;

This would be better as -EINVAL.

Also this is a bug fix because the original code returned a positive
value and then checked for a negative.  The caller just spams
/var/log/message and returns success which isn't right either.

Ah staging code...

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux