From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751163AbeAMFpu (ORCPT + 1 other); Sat, 13 Jan 2018 00:45:50 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:40426 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750728AbeAMFpt (ORCPT ); Sat, 13 Jan 2018 00:45:49 -0500 X-Google-Smtp-Source: ACJfBotMsYlV6773h5xjFXonQ3P0fa6ucYzo7KDqA7IvfMzpI5FwyPXLRxU618FVmKmwD72/QWo4fw== From: Sumit Pundir To: oleg.drokin@intel.com Cc: andreas.dilger@intel.com, jsimmons@infradead.org, gregkh@linuxfoundation.org, lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: lustre: lmv: prefer kstrto to single variable sscanf Date: Sat, 13 Jan 2018 11:15:39 +0530 Message-Id: <1515822339-323-1-git-send-email-pundirsumit11@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: A kstrto should be preferred for a single variable instead of sscanf to convert string to the the required datatype. Issue reported by checkpatch.pl Signed-off-by: Sumit Pundir --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index c2c57f6..09ed154 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1319,14 +1319,16 @@ static int lmv_process_config(struct obd_device *obd, u32 len, void *buf) obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1)); - if (sscanf(lustre_cfg_buf(lcfg, 2), "%u", &index) != 1) { - rc = -EINVAL; + rc = kstrtou32(lustre_cfg_buf(lcfg, 2), 0, &index); + + if (rc) goto out; - } - if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", &gen) != 1) { - rc = -EINVAL; + + rc = kstrtoint(lustre_cfg_buf(lcfg, 3), 0, &gen); + + if (rc) goto out; - } + rc = lmv_add_target(obd, &obd_uuid, index, gen); goto out; default: -- 2.7.4