From ca91c215b00e405b9dad5b3fd3664bc131e168c9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 11 Feb 2019 10:56:11 -0500 Subject: [PATCH] LU-9859 libcfs: use strim instead of cfs_trimwhite. Linux lib provides identical functionality to cfs_trimwhite, so discard that code and use the standard. Linux-commit: 213b14b1fa55790f55b180ed5121b07f037c7ddd Change-Id: Ide9d829aef554541a3dfb65ecb305e89c7ddf74a Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/34168 Reviewed-by: Ben Evans Reviewed-by: Gu Zheng Tested-by: Jenkins Reviewed-by: Yang Sheng Tested-by: Maloo Reviewed-by: Oleg Drokin --- contrib/scripts/spelling.txt | 1 + libcfs/include/libcfs/libcfs_string.h | 1 - libcfs/libcfs/libcfs_cpu.c | 8 ++++---- libcfs/libcfs/libcfs_string.c | 20 -------------------- lnet/lnet/router_proc.c | 2 +- 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/contrib/scripts/spelling.txt b/contrib/scripts/spelling.txt index fd28a99..6e07a89 100644 --- a/contrib/scripts/spelling.txt +++ b/contrib/scripts/spelling.txt @@ -82,6 +82,7 @@ CFS_PAGE_MASK||PAGE_MASK CFS_PAGE_SIZE||PAGE_SIZE cfs_proc_dir_entry_t||struct proc_dir_entry cfs_rcu_head_t||struct rcu_head +cfs_trimwhite||strim cfs_time_add_64||ktime_add cfs_time_after||time_after cfs_time_aftereq||time_after_eq diff --git a/libcfs/include/libcfs/libcfs_string.h b/libcfs/include/libcfs/libcfs_string.h index 4d9dbde..daf6d34 100644 --- a/libcfs/include/libcfs/libcfs_string.h +++ b/libcfs/include/libcfs/libcfs_string.h @@ -73,7 +73,6 @@ struct cfs_expr_list { struct list_head el_exprs; }; -char *cfs_trimwhite(char *str); int cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res); int cfs_str2num_check(char *str, int nob, unsigned *num, unsigned min, unsigned max); diff --git a/libcfs/libcfs/libcfs_cpu.c b/libcfs/libcfs/libcfs_cpu.c index c80f9d4..6eb9591 100644 --- a/libcfs/libcfs/libcfs_cpu.c +++ b/libcfs/libcfs/libcfs_cpu.c @@ -948,7 +948,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern) return ERR_PTR(-ENOMEM); } - str = cfs_trimwhite(pattern_dup); + str = strim(pattern_dup); if (*str == 'n' || *str == 'N') { str++; /* skip 'N' char */ node = 1; /* NUMA pattern */ @@ -1006,7 +1006,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern) high = node ? nr_node_ids - 1 : nr_cpu_ids - 1; - for (str = cfs_trimwhite(str), c = 0; /* until break */; c++) { + for (str = strim(str), c = 0; /* until break */; c++) { struct cfs_range_expr *range; struct cfs_expr_list *el; int n; @@ -1045,7 +1045,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern) goto err_free_table; } - str = cfs_trimwhite(str + n); + str = strim(str + n); if (str != bracket) { CERROR("Invalid pattern '%s'\n", str); rc = -EINVAL; @@ -1091,7 +1091,7 @@ static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern) goto err_free_table; } - str = cfs_trimwhite(bracket + 1); + str = strim(bracket + 1); } kfree(pattern_dup); diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index b460df3..ee39d23 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -165,26 +165,6 @@ out: } EXPORT_SYMBOL(cfs_firststr); -char * -cfs_trimwhite(char *str) -{ - char *end; - - while (isspace(*str)) - str++; - - end = str + strlen(str); - while (end > str) { - if (!isspace(end[-1])) - break; - end--; - } - - *end = 0; - return str; -} -EXPORT_SYMBOL(cfs_trimwhite); - /** * Extracts tokens from strings. * diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c index c0c5c25..a839507 100644 --- a/lnet/lnet/router_proc.c +++ b/lnet/lnet/router_proc.c @@ -878,7 +878,7 @@ static int __proc_lnet_portal_rotor(void *data, int write, if (rc < 0) goto out; - tmp = cfs_trimwhite(buf); + tmp = strim(buf); rc = -EINVAL; lnet_res_lock(0); -- 1.8.3.1