All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Saurabh Sengar <saurabh.truth@gmail.com>
Cc: w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca,
	samuel.thibault@ens-lyon.org, gregkh@linuxfoundation.org,
	speakup@linux-speakup.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: speakup: kobjects: Return the error type to caller
Date: Mon, 7 Dec 2015 09:48:47 +0300	[thread overview]
Message-ID: <20151207064847.GA18797@mwanda> (raw)
In-Reply-To: <1449240153-3927-1-git-send-email-saurabh.truth@gmail.com>

On Fri, Dec 04, 2015 at 08:12:33PM +0530, Saurabh Sengar wrote:
> Inorder to notify the user that value is not successfuly set in sys
> entry, error should be returned from store function instead of count
> 
> Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
> ---
>  drivers/staging/speakup/kobjects.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index fdfeb42..b3a83fb 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -640,7 +640,8 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
>  			len = E_INC;
>  		else
>  			len = E_SET;
> -		if (kstrtol(cp, 10, &value) == 0)
> +		ret = kstrtol(cp, 10, &value);
> +		if (!ret)
>  			ret = spk_set_num_var(value, param, len);

Both kstrtol() and spk_set_num_var() return -ERANGE.  The next lines
expect that if we got -ERANGE, then it came from spk_set_num_var() so
they print a wrong message.

>  		else
>  			pr_warn("overflow or parsing error has occurred");
> @@ -688,6 +689,8 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
>  
>  	if (ret == -ERESTART)
>  		pr_info("%s reset to default value\n", param->name);

Is this really true?

This function is so weird and broken.  Please look at it some more and
fix it harder with a mallet.

regards,
dan carpenter


  reply	other threads:[~2015-12-07  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 14:42 [PATCH] Staging: speakup: kobjects: Return the error type to caller Saurabh Sengar
2015-12-07  6:48 ` Dan Carpenter [this message]
2015-12-07  7:16   ` Saurabh Sengar
2015-12-07  8:31     ` Dan Carpenter
2015-12-07  9:59       ` [PATCH v2] " Saurabh Sengar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151207064847.GA18797@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=chris@the-brannons.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kirk@reisers.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=saurabh.truth@gmail.com \
    --cc=speakup@linux-speakup.org \
    --cc=w.d.hubbs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.