Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964848AbcLPQ4H (ORCPT ); Fri, 16 Dec 2016 11:56:07 -0500 Received: from mx2.suse.de ([195.135.220.15]:38614 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964817AbcLPQz6 (ORCPT ); Fri, 16 Dec 2016 11:55:58 -0500 Date: Fri, 16 Dec 2016 17:55:55 +0100 From: Petr Mladek To: Josh Poimboeuf Cc: Jessica Yu , Jiri Kosina , Miroslav Benes , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michael Ellerman , Heiko Carstens , x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Vojtech Pavlik , Jiri Slaby , Chris J Arges , Andy Lutomirski , Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH v3 11/15] livepatch: use kstrtobool() in enabled_store() Message-ID: <20161216165555.GK393@pathway.suse.cz> References: <50c4817cbccd6e6cfd0c85c96bf127f84ee79cc8.1481220077.git.jpoimboe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50c4817cbccd6e6cfd0c85c96bf127f84ee79cc8.1481220077.git.jpoimboe@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1018 Lines: 34 On Thu 2016-12-08 12:08:36, Josh Poimboeuf wrote: > The sysfs enabled value is a boolean, so kstrtobool() is a better fit > for parsing the input string since it does the range checking for us. > > Suggested-by: Petr Mladek > Signed-off-by: Josh Poimboeuf > --- > kernel/livepatch/core.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > index 6a137e1..8ca8a0e 100644 > --- a/kernel/livepatch/core.c > +++ b/kernel/livepatch/core.c > @@ -408,26 +408,23 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, > { > struct klp_patch *patch; > int ret; > - unsigned long val; > + bool enabled; > > - ret = kstrtoul(buf, 10, &val); > + ret = kstrtobool(buf, &enabled); > if (ret) > return -EINVAL; I would return "ret" here. It is -EINVAL as well but... ;-) Anyway, feel free to use: Reviewed-by: Petr Mladek Best Regards, Petr