Whamcloud - gitweb
LU-9859 libcfs: discard cfs_gettok and cfs_str2num_check 44/50844/3
authorMr NeilBrown <neilb@suse.de>
Thu, 24 Aug 2023 14:32:40 +0000 (10:32 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:29:40 +0000 (06:29 +0000)
cfs_gettok() and cfs_str2num_check() are no longer used in the kernel,
so remove them.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I49a8378f049a936a742681293db616f7eb9b11af
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50844
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/libcfs_string.h
libcfs/libcfs/libcfs_string.c

index 5d07a1b..dddae1f 100644 (file)
@@ -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);
index 1c202df..c9bffe3 100644 (file)
@@ -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 \<range_expr\> token of the syntax. If \a bracketed is false,
  * \a src should only have a single token which can be \<number\> or  \*
  *