Whamcloud - gitweb
LU-9325 ptlrpc: replace simple_strtol with kstrtol 85/32785/8
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 5 Jul 2018 03:56:02 +0000 (23:56 -0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Aug 2018 02:22:19 +0000 (02:22 +0000)
Eventually simple_strtol() will be removed so replace its use in
the ptlrpc with kstrtoXXX() class of functions.

Change-Id: I41b44c5dc329832a901c1772a9ba0608df30282a
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32785
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Nikitas Angelinas <nikitas.angelinas@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/ptlrpc/gss/gss_svc_upcall.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/nrs_crr.c
lustre/ptlrpc/nrs_orr.c

index 35ed8d1..84de7c9 100644 (file)
@@ -298,7 +298,6 @@ static struct cache_head *rsi_alloc(void)
 static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen)
 {
         char           *buf = mesg;
-        char           *ep;
         int             len;
         struct rsi      rsii, *rsip = NULL;
         time_t          expiry;
@@ -340,18 +339,21 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen)
         if (len <= 0)
                 goto out;
 
-        /* major */
-        rsii.major_status = simple_strtol(buf, &ep, 10);
-        if (*ep)
-                goto out;
+       /* major */
+       status = kstrtoint(buf, 10, &rsii.major_status);
+       if (status)
+               goto out;
 
-        /* minor */
-        len = qword_get(&mesg, buf, mlen);
-        if (len <= 0)
-                goto out;
-        rsii.minor_status = simple_strtol(buf, &ep, 10);
-        if (*ep)
-                goto out;
+       /* minor */
+       len = qword_get(&mesg, buf, mlen);
+       if (len <= 0) {
+               status = -EINVAL;
+               goto out;
+       }
+
+       status = kstrtoint(buf, 10, &rsii.minor_status);
+       if (status)
+               goto out;
 
         /* out_handle */
         len = qword_get(&mesg, buf, mlen);
index 8d081e2..301088f 100644 (file)
@@ -1397,14 +1397,14 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer,
        uuid = kbuf + prefix_len;
        ptr = strstr(uuid, "::");
        if (ptr) {
-               __u32 inst;
-               char *endptr;
+               u32 inst;
+               int rc;
 
                *ptr = 0;
                do_reconn = 0;
                ptr += 2; /* Skip :: */
-               inst = simple_strtol(ptr, &endptr, 10);
-               if (*endptr) {
+               rc = kstrtouint(ptr, 10, &inst);
+               if (rc) {
                        CERROR("config: wrong instance # %s\n", ptr);
                } else if (inst != imp->imp_connect_data.ocd_instance) {
                        CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted "
index 2d56bdb..31a0629 100644 (file)
@@ -729,7 +729,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
        val = lprocfs_find_named_value(kernbuf, NRS_LPROCFS_QUANTUM_NAME_REG,
                                       &count_copy);
        if (val != kernbuf) {
-               quantum_reg = simple_strtol(val, NULL, 10);
+               rc = kstrtol(val, 10, &quantum_reg);
+               if (rc)
+                       return rc;
 
                queue |= PTLRPC_NRS_QUEUE_REG;
        }
@@ -745,7 +747,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
                if (!nrs_svc_has_hp(svc))
                        return -ENODEV;
 
-               quantum_hp = simple_strtol(val, NULL, 10);
+               rc = kstrtol(val, 10, &quantum_hp);
+               if (rc)
+                       return rc;
 
                queue |= PTLRPC_NRS_QUEUE_HP;
        }
@@ -755,10 +759,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
         * value
         */
        if (queue == 0) {
-               if (!isdigit(kernbuf[0]))
-                       return -EINVAL;
-
-               quantum_reg = simple_strtol(kernbuf, NULL, 10);
+               rc = kstrtol(kernbuf, 10, &quantum_reg);
+               if (rc)
+                       return rc;
 
                queue = PTLRPC_NRS_QUEUE_REG;
 
index 85fc3a3..25dea5c 100644 (file)
@@ -1307,8 +1307,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file,
        val = lprocfs_find_named_value(kernbuf, NRS_LPROCFS_QUANTUM_NAME_REG,
                                       &count_copy);
        if (val != kernbuf) {
-               quantum_reg = simple_strtol(val, NULL, 10);
-
+               rc = kstrtol(val, 10, &quantum_reg);
+               if (rc)
+                       return rc;
                queue |= PTLRPC_NRS_QUEUE_REG;
        }
 
@@ -1323,7 +1324,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file,
                if (!nrs_svc_has_hp(svc))
                        return -ENODEV;
 
-               quantum_hp = simple_strtol(val, NULL, 10);
+               rc = kstrtol(val, 10, &quantum_hp);
+               if (rc)
+                       return rc;
 
                queue |= PTLRPC_NRS_QUEUE_HP;
        }
@@ -1333,10 +1336,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file,
         * value
         */
        if (queue == 0) {
-               if (!isdigit(kernbuf[0]))
-                       return -EINVAL;
-
-               quantum_reg = simple_strtol(kernbuf, NULL, 10);
+               rc = kstrtol(kernbuf, 10, &quantum_reg);
+               if (rc)
+                       return rc;
 
                queue = PTLRPC_NRS_QUEUE_REG;