[PATCH] staging: lustre: Replace sscanf with kstrtoint

Cristina Moraru cristina.moraru09 at gmail.com
Sun Oct 18 02:00:52 EEST 2015


Replace single variable sscanf with specialized function
kstrtoint at the suggestion of checkpatch.pl, to fix
'WARNING: Prefer kstrto<type> to single variable sscanf'

Signed-off-by: Cristina Moraru <cristina.moraru09 at gmail.com>
---
 drivers/staging/lustre/lustre/lov/lov_obd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index c3be0b5..59445fc 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -914,11 +914,13 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
 
 		obd_str2uuid(&obd_uuid,  lustre_cfg_buf(lcfg, 1));
 
-		if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", indexp) != 1) {
+		if (kstrtoint(lustre_cfg_buf(lcfg, 2), 10, indexp) ||
+				*indexp != 1) {
 			rc = -EINVAL;
 			goto out;
 		}
-		if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", genp) != 1) {
+		if (kstrtoint(lustre_cfg_buf(lcfg, 3), 10, genp) ||
+				*genp != 1) {
 			rc = -EINVAL;
 			goto out;
 		}
-- 
1.9.1



More information about the firefly mailing list