From 88141538c475b99fe911c54a60e5c004c5296a55 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 24 Aug 2023 10:32:40 -0400 Subject: [PATCH] LU-9859 libcfs: discard cfs_gettok and cfs_str2num_check cfs_gettok() and cfs_str2num_check() are no longer used in the kernel, so remove them. Test-Parameters: trivial Signed-off-by: Mr NeilBrown Change-Id: I49a8378f049a936a742681293db616f7eb9b11af Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50844 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Patrick Farrell Reviewed-by: Timothy Day Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_string.h | 3 - libcfs/libcfs/libcfs_string.c | 115 ---------------------------------- 2 files changed, 118 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_string.h b/libcfs/include/libcfs/libcfs_string.h index 5d07a1b..dddae1f 100644 --- a/libcfs/include/libcfs/libcfs_string.h +++ b/libcfs/include/libcfs/libcfs_string.h @@ -69,9 +69,6 @@ struct cfs_expr_list { struct list_head el_exprs; }; -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); int cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list); int cfs_expr_list_values(struct cfs_expr_list *expr_list, int max, __u32 **values); diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index 1c202df..c9bffe3 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -121,121 +121,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), EXPORT_SYMBOL(cfs_str2mask); /** - * Extracts tokens from strings. - * - * Looks for \a delim in string \a next, sets \a res to point to - * substring before the delimiter, sets \a next right after the found - * delimiter. - * - * \retval 1 if \a res points to a string of non-whitespace characters - * \retval 0 otherwise - */ -int -cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res) -{ - char *end; - - if (next->ls_str == NULL) - return 0; - - /* skip leading white spaces */ - while (next->ls_len) { - if (!isspace(*next->ls_str)) - break; - next->ls_str++; - next->ls_len--; - } - - if (next->ls_len == 0) /* whitespaces only */ - return 0; - - if (*next->ls_str == delim) { - /* first non-writespace is the delimiter */ - return 0; - } - - res->ls_str = next->ls_str; - end = memchr(next->ls_str, delim, next->ls_len); - if (end == NULL) { - /* there is no the delimeter in the string */ - end = next->ls_str + next->ls_len; - next->ls_str = NULL; - next->ls_len = 0; - } else { - next->ls_str = end + 1; - next->ls_len -= (end - res->ls_str + 1); - } - - /* skip ending whitespaces */ - while (--end != res->ls_str) { - if (!isspace(*end)) - break; - } - - res->ls_len = end - res->ls_str + 1; - return 1; -} -EXPORT_SYMBOL(cfs_gettok); - -/** - * Converts string to integer. - * - * Accepts decimal and hexadecimal number recordings. - * - * \retval 1 if first \a nob chars of \a str convert to decimal or - * hexadecimal integer in the range [\a min, \a max] - * \retval 0 otherwise - */ -int -cfs_str2num_check(char *str, int nob, unsigned *num, - unsigned min, unsigned max) -{ - bool all_numbers = true; - char *endp, cache; - int len; - int rc; - - endp = strim(str); - /** - * kstrouint can only handle strings composed - * of only numbers. We need to scan the string - * passed in for the first non-digit character - * and end the string at that location. If we - * don't find any non-digit character we still - * need to place a '\0' at position len since - * we are not interested in the rest of the - * string which is longer than len in size. - * After we are done the character at the - * position we placed '\0' must be restored. - */ - len = min((int)strlen(endp), nob); - for (; endp < str + len; endp++) { - if (!isxdigit(*endp) && *endp != '-' && - *endp != '+') { - all_numbers = false; - break; - } - } - - /* Eat trailing space */ - if (!all_numbers && isspace(*endp)) { - all_numbers = true; - endp--; - } - - cache = *endp; - *endp = '\0'; - - rc = kstrtouint(str, 0, num); - *endp = cache; - if (rc || !all_numbers) - return 0; - - return (*num >= min && *num <= max); -} -EXPORT_SYMBOL(cfs_str2num_check); - -/** * Parses \ token of the syntax. If \a bracketed is false, * \a src should only have a single token which can be \ or \* * -- 1.8.3.1