From ee5eb07d2f41ac603981c49cc7000f8938aefbeb Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Tue, 24 Nov 2020 13:28:01 +1100 Subject: [PATCH] LU-6142 libcfs: discard cfs_firststr The effect of cfs_firststr() can easily achieved with skip_space() and strsep(). So use that instead. Signed-off-by: Mr NeilBrown Change-Id: Idcf8aa50b6aad052f7ee5341ce6d635495aa4990 Reviewed-on: https://review.whamcloud.com/40860 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_string.h | 2 -- libcfs/libcfs/libcfs_string.c | 28 ---------------------------- lustre/mdt/mdt_lproc.c | 3 ++- lustre/obdclass/lprocfs_status_server.c | 3 ++- 4 files changed, 4 insertions(+), 32 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_string.h b/libcfs/include/libcfs/libcfs_string.h index daf6d34..f74a9cd 100644 --- a/libcfs/include/libcfs/libcfs_string.h +++ b/libcfs/include/libcfs/libcfs_string.h @@ -44,8 +44,6 @@ char *cfs_strrstr(const char *haystack, const char *needle); /* Convert a text string to a bitmask */ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), int *oldmask, int minmask, int allmask); -/* trim leading and trailing space characters */ -char *cfs_firststr(char *str, size_t size); /** * Structure to represent NULL-less strings. diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index 2ff9708..1ba1c24 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -138,34 +138,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), } EXPORT_SYMBOL(cfs_str2mask); -/* get the first string out of @str */ -char *cfs_firststr(char *str, size_t size) -{ - size_t i = 0; - char *end; - - /* trim leading spaces */ - while (i < size && *str && isspace(*str)) { - ++i; - ++str; - } - - /* string with all spaces */ - if (*str == '\0') - goto out; - - end = str; - while (i < size && *end != '\0' && !isspace(*end)) { - ++i; - ++end; - } - - *end = '\0'; -out: - return str; -} -EXPORT_SYMBOL(cfs_firststr); - /** * Extracts tokens from strings. * diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 113a9b1..60d6ec2 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -440,7 +440,8 @@ lprocfs_mds_evict_client_seq_write(struct file *file, const char __user *buf, */ if (copy_from_user(kbuf, buf, min_t(unsigned long, BUFLEN - 1, count))) GOTO(out, rc = -EFAULT); - tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count)); + tmpbuf = skip_spaces(kbuf); + tmpbuf = strsep(&tmpbuf, " \t\n\f\v\r"); if (strncmp(tmpbuf, "nid:", 4) != 0) { count = lprocfs_evict_client_seq_write(file, buf, count, off); diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index 3c82dd2..f8626ba 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -124,7 +124,8 @@ lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer, count = -EFAULT; goto out; } - tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count)); + tmpbuf = skip_spaces(kbuf); + tmpbuf = strsep(&tmpbuf, " \t\n\f\v\r"); class_incref(obd, __func__, current); if (strncmp(tmpbuf, "nid:", 4) == 0) -- 1.8.3.1