Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934115AbdCLPvp (ORCPT ); Sun, 12 Mar 2017 11:51:45 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35387 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755742AbdCLPvj (ORCPT ); Sun, 12 Mar 2017 11:51:39 -0400 Date: Sun, 12 Mar 2017 16:51:35 +0100 From: Marcin Ciupak To: Greg Kroah-Hartman Cc: Oleg Drokin , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Andreas Dilger , lustre-devel@lists.lustre.org Subject: Re: [PATCH] staging: lustre: replace simple_strtoul with kstrtoint Message-ID: <20170312155135.GA3487@gentoo> References: <20170309145300.GA2849@gentoo> <20170312133647.GB27791@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170312133647.GB27791@kroah.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1990 Lines: 54 On Sun, Mar 12, 2017 at 02:36:47PM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 09, 2017 at 03:53:00PM +0100, Marcin Ciupak wrote: > > Replace simple_strtoul with kstrtoint. > > Why? Because > > simple_strtoul is marked for obsoletion. as reported by checkpatch.pl. > > > > Signed-off-by: Marcin Ciupak > > --- > > drivers/staging/lustre/lustre/obdclass/obd_mount.c | 20 ++++++++++++++++---- > > 1 file changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > index 8e0d4b1d86dc..4a604e9b3e49 100644 > > --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c > > @@ -924,12 +924,24 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) > > lmd->lmd_flags |= LMD_FLG_ABORT_RECOV; > > clear++; > > } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) { > > - lmd->lmd_recovery_time_soft = max_t(int, > > - simple_strtoul(s1 + 19, NULL, 10), time_min); > > + int res; > > + > > + rc = kstrtoint(s1 + 19, 10, &res); > > + if (rc) > > + lmd->lmd_recovery_time_soft = time_min; > > + else > > + lmd->lmd_recovery_time_soft = max_t(int, res, > > + time_min); > > Are you sure this is correct? Do you really want to use max_t()? Why > is time_min used if there is an error? Can't this all be written a lot > simpler to actually make it semi-sane? > > thanks, > > greg k-h max_t() and time_min were already used in the original code, I did not want to change that. Regarding error handling, I saw two options here: 1. update variable with some fail-safe value and time_min looked good for that or, 2. do not update anything and do nothing or "goto invalid:" but I was not sure about that, so selected first option. If first option is not the best one, what would be better in case of error handling? Thanks, Marcin