Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753758AbbLGHQj (ORCPT ); Mon, 7 Dec 2015 02:16:39 -0500 Received: from mail-ig0-f172.google.com ([209.85.213.172]:32893 "EHLO mail-ig0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753587AbbLGHQh (ORCPT ); Mon, 7 Dec 2015 02:16:37 -0500 MIME-Version: 1.0 In-Reply-To: <20151207064847.GA18797@mwanda> References: <1449240153-3927-1-git-send-email-saurabh.truth@gmail.com> <20151207064847.GA18797@mwanda> Date: Mon, 7 Dec 2015 12:46:37 +0530 Message-ID: Subject: Re: [PATCH] Staging: speakup: kobjects: Return the error type to caller From: Saurabh Sengar To: Dan Carpenter Cc: William Hubbs , Christopher Brannon , kirk@reisers.ca, Samuel Thibault , Greg KH , speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2387 Lines: 59 On 7 December 2015 at 12:18, Dan Carpenter wrote: > 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 >> --- >> 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. Yes I understand this. And in case we got -ERANGE from spk_set_num_var, it is printing the error message. I have tested this too by passing the out of range values to few parameters. > >> 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? Sorry, I am not sure here what you mean here. I have not implemented it. > > This function is so weird and broken. Please look at it some more and > fix it harder with a mallet. You mean I broke it ? I don't think so, I have tested the functionality before submitting the patch. If you mean that this function already not in good shape, I understand and agree with you. > > regards, > dan carpenter > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/