Whamcloud - gitweb
LU-6142 libcfs: discard cfs_firststr 60/40860/2
authorMr NeilBrown <neilb@suse.de>
Tue, 24 Nov 2020 02:28:01 +0000 (13:28 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 22:10:54 +0000 (22:10 +0000)
The effect of cfs_firststr() can easily achieved with
skip_space() and strsep().

So use that instead.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Idcf8aa50b6aad052f7ee5341ce6d635495aa4990
Reviewed-on: https://review.whamcloud.com/40860
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.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
lustre/mdt/mdt_lproc.c
lustre/obdclass/lprocfs_status_server.c

index daf6d34..f74a9cd 100644 (file)
@@ -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.
index 2ff9708..1ba1c24 100644 (file)
@@ -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.
  *
index 113a9b1..60d6ec2 100644 (file)
@@ -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);
index 3c82dd2..f8626ba 100644 (file)
@@ -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)