[19/37] lustre: discard lprocfs_strnstr()
diff mbox series

Message ID 155053494582.24125.9057041272800982944.stgit@noble.brown
State New
Headers show
Series
  • More lustre patches from obdclass
Related show

Commit Message

NeilBrown Feb. 19, 2019, 12:09 a.m. UTC
This is identical to strnstr() in lib/string.h,
so just use that.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../lustre/lustre/obdclass/lprocfs_status.c        |   19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

Comments

James Simmons Feb. 24, 2019, 5:53 p.m. UTC | #1
> This is identical to strnstr() in lib/string.h,
> so just use that.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../lustre/lustre/obdclass/lprocfs_status.c        |   19 +------------------
>  1 file changed, 1 insertion(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> index 76d298337e95..27d73c95403d 100644
> --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
> @@ -1552,22 +1552,6 @@ int lprocfs_write_frac_u64_helper(const char __user *buffer,
>  }
>  EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
>  
> -static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
> -{
> -	size_t l2;
> -
> -	l2 = strlen(s2);
> -	if (!l2)
> -		return (char *)s1;
> -	while (len >= l2) {
> -		len--;
> -		if (!memcmp(s1, s2, l2))
> -			return (char *)s1;
> -		s1++;
> -	}
> -	return NULL;
> -}
> -
>  /**
>   * Find the string \a name in the input \a buffer, and return a pointer to the
>   * value immediately following \a name, reducing \a count appropriately.
> @@ -1579,8 +1563,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
>  	char *val;
>  	size_t buflen = *count;
>  
> -	/* there is no strnstr() in rhel5 and ubuntu kernels */
> -	val = lprocfs_strnstr(buffer, name, buflen);
> +	val = strnstr(buffer, name, buflen);
>  	if (!val)
>  		return (char *)buffer;
>  
> 
> 
>

Patch
diff mbox series

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 76d298337e95..27d73c95403d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1552,22 +1552,6 @@  int lprocfs_write_frac_u64_helper(const char __user *buffer,
 }
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
 
-static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len)
-{
-	size_t l2;
-
-	l2 = strlen(s2);
-	if (!l2)
-		return (char *)s1;
-	while (len >= l2) {
-		len--;
-		if (!memcmp(s1, s2, l2))
-			return (char *)s1;
-		s1++;
-	}
-	return NULL;
-}
-
 /**
  * Find the string \a name in the input \a buffer, and return a pointer to the
  * value immediately following \a name, reducing \a count appropriately.
@@ -1579,8 +1563,7 @@  char *lprocfs_find_named_value(const char *buffer, const char *name,
 	char *val;
 	size_t buflen = *count;
 
-	/* there is no strnstr() in rhel5 and ubuntu kernels */
-	val = lprocfs_strnstr(buffer, name, buflen);
+	val = strnstr(buffer, name, buflen);
 	if (!val)
 		return (char *)buffer;