On Wed, Dec 10, 2014 at 10:54:35PM +0800, Matthew Tyler wrote:
> This patch fixes a trailing statement warning found by checkpatch.pl
>
> Signed-off-by: Matthew Tyler <[email protected]>
> ---
> drivers/staging/lustre/lustre/libcfs/libcfs_string.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
> b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
> index e67a18d..1cc4afb 100644
> --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
> +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c
> @@ -48,7 +48,7 @@ int cfs_str2mask(const char *str, const char
> *(*bit2str)(int bit),
> {
> const char *debugstr;
> char op = 0;
> - int newmask = minmask, i, len, found = 0;
> + int newmask = minmask, i, len = 0, found = 0;
>
> /* <str> must be a list of tokens separated by whitespace
> * and optionally an operator ('+' or '-'). If an operator
> @@ -72,8 +72,9 @@ int cfs_str2mask(const char *str, const char
> *(*bit2str)(int bit),
> }
>
> /* find token length */
> - for (len = 0; str[len] != 0 && !isspace(str[len]) &&
> - str[len] != '+' && str[len] != '-'; len++);
> + while (str[len] != 0 && !isspace(str[len]) &&
> + str[len] != '+' && str[len] != '-')
> + len++;
Sure, I guess the while loop is better than the for loop. The patch
description sucks. Move the len = 0 next to the code which uses len.
Fix the indenting. Use '\0' instead of 0 for characters.
Something like:
len = 0;
while (str[len] != '\0' && !isspace(str[len]) &&
str[len] != '+' && str[len] != '-')
len++;
regards,
dan carpenter
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel