From 8f37d64b6bc9111ff20ffb0bd22daf8fb9c8c159 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 4 Jul 2018 23:56:02 -0400 Subject: [PATCH] LU-9325 ptlrpc: replace simple_strtol with kstrtol 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 Reviewed-on: https://review.whamcloud.com/32785 Reviewed-by: Andreas Dilger Reviewed-by: Nikitas Angelinas Tested-by: Jenkins Tested-by: Maloo --- lustre/ptlrpc/gss/gss_svc_upcall.c | 26 ++++++++++++++------------ lustre/ptlrpc/lproc_ptlrpc.c | 8 ++++---- lustre/ptlrpc/nrs_crr.c | 15 +++++++++------ lustre/ptlrpc/nrs_orr.c | 16 +++++++++------- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index 35ed8d1..84de7c9 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -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); diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 8d081e2..301088f 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -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 " diff --git a/lustre/ptlrpc/nrs_crr.c b/lustre/ptlrpc/nrs_crr.c index 2d56bdb..31a0629 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -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; diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index 85fc3a3..25dea5c 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -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; -- 1.8.3.1