From: James Simmons Date: Thu, 7 Jun 2018 00:52:17 +0000 (-0400) Subject: LU-9325 llog: replace simple_strtol with kstrtol X-Git-Tag: 2.11.53~15 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F32598%2F3;p=fs%2Flustre-release.git LU-9325 llog: replace simple_strtol with kstrtol Eventually simple_strtol will be removed so replace its use in the llog_ioctl code with kstrtoxxx() functions. Change-Id: I55a4e97837a1d9e0134dde92f0c2380f07691ab9 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/32598 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Mike Pershin Reviewed-by: Alex Zhuravlev --- diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index bae7b0f..4350450 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -39,8 +39,10 @@ static int str2logid(struct llog_logid *logid, char *str, int len) { - char *start, *end, *endp; - __u64 id, seq; + unsigned long long id, seq; + char *start, *end; + u32 ogen; + int rc; ENTRY; start = str; @@ -71,21 +73,22 @@ static int str2logid(struct llog_logid *logid, char *str, int len) RETURN(-EINVAL); *end = '\0'; - id = simple_strtoull(start, &endp, 0); - if (endp != end) - RETURN(-EINVAL); + rc = kstrtoull(start, 0, &id); + if (rc) + RETURN(rc); - start = ++end; - if (start - str >= len - 1) - RETURN(-EINVAL); - end = strchr(start, '#'); - if (end == NULL || end == start) - RETURN(-EINVAL); + start = ++end; + if (start - str >= len - 1) + RETURN(-EINVAL); - *end = '\0'; - seq = simple_strtoull(start, &endp, 0); - if (endp != end) - RETURN(-EINVAL); + end = strchr(start, '#'); + if (!end || end == start) + RETURN(-EINVAL); + + *end = '\0'; + rc = kstrtoull(start, 0, &seq); + if (rc) + RETURN(rc); ostid_set_seq(&logid->lgl_oi, seq); if (ostid_set_id(&logid->lgl_oi, id)) @@ -94,11 +97,13 @@ static int str2logid(struct llog_logid *logid, char *str, int len) start = ++end; if (start - str >= len - 1) RETURN(-EINVAL); - logid->lgl_ogen = simple_strtoul(start, &endp, 16); - if (*endp != '\0') + + rc = kstrtouint(start, 16, &ogen); + if (rc) RETURN(-EINVAL); + logid->lgl_ogen = ogen; - RETURN(0); + RETURN(0); #else RETURN(-EINVAL); #endif @@ -107,29 +112,31 @@ static int str2logid(struct llog_logid *logid, char *str, int len) static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data) { - struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data; + struct obd_ioctl_data *ioc_data = data; static int l, remains; static long from, to; - static char *out; - char *endp; - int cur_index, rc = 0; - - ENTRY; + static char *out; + int cur_index; + int rc = 0; + ENTRY; if (ioc_data && ioc_data->ioc_inllen1 > 0) { - l = 0; - remains = ioc_data->ioc_inllen4 + - cfs_size_round(ioc_data->ioc_inllen1) + - cfs_size_round(ioc_data->ioc_inllen2) + - cfs_size_round(ioc_data->ioc_inllen3); - from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); - if (*endp != '\0') - RETURN(-EINVAL); - to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); - if (*endp != '\0') - RETURN(-EINVAL); - ioc_data->ioc_inllen1 = 0; - out = ioc_data->ioc_bulk; + l = 0; + remains = ioc_data->ioc_inllen4 + + round_up(ioc_data->ioc_inllen1, 8) + + round_up(ioc_data->ioc_inllen2, 8) + + round_up(ioc_data->ioc_inllen3, 8); + + rc = kstrtol(ioc_data->ioc_inlbuf2, 0, &from); + if (rc) + RETURN(rc); + + rc = kstrtol(ioc_data->ioc_inlbuf3, 0, &to); + if (rc) + RETURN(rc); + + ioc_data->ioc_inllen1 = 0; + out = ioc_data->ioc_bulk; } cur_index = rec->lrh_index; @@ -194,29 +201,32 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data) { - struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data; + struct obd_ioctl_data *ioc_data = data; static int l, remains; static long from, to; - static char *out; - char *endp; - int cur_index; - - ENTRY; - if (ioc_data != NULL && ioc_data->ioc_inllen1 > 0) { - l = 0; - remains = ioc_data->ioc_inllen4 + - cfs_size_round(ioc_data->ioc_inllen1) + - cfs_size_round(ioc_data->ioc_inllen2) + - cfs_size_round(ioc_data->ioc_inllen3); - from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); - if (*endp != '\0') - RETURN(-EINVAL); - to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); - if (*endp != '\0') - RETURN(-EINVAL); - out = ioc_data->ioc_bulk; - ioc_data->ioc_inllen1 = 0; - } + static char *out; + int cur_index; + int rc; + + ENTRY; + if (ioc_data && ioc_data->ioc_inllen1 > 0) { + l = 0; + remains = ioc_data->ioc_inllen4 + + round_up(ioc_data->ioc_inllen1, 8) + + round_up(ioc_data->ioc_inllen2, 8) + + round_up(ioc_data->ioc_inllen3, 8); + + rc = kstrtol(ioc_data->ioc_inlbuf2, 0, &from); + if (rc) + RETURN(rc); + + rc = kstrtol(ioc_data->ioc_inlbuf3, 0, &to); + if (rc) + RETURN(rc); + + out = ioc_data->ioc_bulk; + ioc_data->ioc_inllen1 = 0; + } cur_index = rec->lrh_index; if (cur_index < from) @@ -382,11 +392,12 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, case OBD_IOC_LLOG_CANCEL: { struct llog_cookie cookie; struct llog_logid plain; - char *endp; + u32 lgc_index; - cookie.lgc_index = simple_strtoul(data->ioc_inlbuf3, &endp, 0); - if (*endp != '\0') - GOTO(out_close, rc = -EINVAL); + rc = kstrtouint(data->ioc_inlbuf3, 0, &lgc_index); + if (rc) + GOTO(out_close, rc); + cookie.lgc_index = lgc_index; if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) { rc = llog_cancel_rec(env, handle, cookie.lgc_index);