mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sumit Pundir <pundirsumit11@gmail.com>
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<type> to single variable sscanf
Date: Sat, 13 Jan 2018 11:15:39 +0530	[thread overview]
Message-ID: <1515822339-323-1-git-send-email-pundirsumit11@gmail.com> (raw)

A kstrto<type> 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 <pundirsumit11@gmail.com>
---
 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

                 reply	other threads:[~2018-01-13  5:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1515822339-323-1-git-send-email-pundirsumit11@gmail.com \
    --to=pundirsumit11@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®