Commit 3f9773a5 authored by Matthew Tyler's avatar Matthew Tyler Committed by Greg Kroah-Hartman

staging: lustre: Cleanup cfs_str2mask in libcfs_string.c

- Replace body-less for-loop with while loop
- Use '\0' for null character instead of 0
Signed-off-by: default avatarMatthew Tyler <matt.tyler@flashics.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 51566472
...@@ -47,7 +47,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), ...@@ -47,7 +47,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
int *oldmask, int minmask, int allmask) int *oldmask, int minmask, int allmask)
{ {
const char *debugstr; const char *debugstr;
char op = 0; char op = '\0';
int newmask = minmask, i, len, found = 0; int newmask = minmask, i, len, found = 0;
/* <str> must be a list of tokens separated by whitespace /* <str> must be a list of tokens separated by whitespace
...@@ -55,10 +55,10 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), ...@@ -55,10 +55,10 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
* appears first in <str>, '*oldmask' is used as the starting point * appears first in <str>, '*oldmask' is used as the starting point
* (relative), otherwise minmask is used (absolute). An operator * (relative), otherwise minmask is used (absolute). An operator
* applies to all following tokens up to the next operator. */ * applies to all following tokens up to the next operator. */
while (*str != 0) { while (*str != '\0') {
while (isspace(*str)) while (isspace(*str))
str++; str++;
if (*str == 0) if (*str == '\0')
break; break;
if (*str == '+' || *str == '-') { if (*str == '+' || *str == '-') {
op = *str++; op = *str++;
...@@ -67,13 +67,15 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), ...@@ -67,13 +67,15 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
newmask = *oldmask; newmask = *oldmask;
while (isspace(*str)) while (isspace(*str))
str++; str++;
if (*str == 0) /* trailing op */ if (*str == '\0') /* trailing op */
return -EINVAL; return -EINVAL;
} }
/* find token length */ /* find token length */
for (len = 0; str[len] != 0 && !isspace(str[len]) && len = 0;
str[len] != '+' && str[len] != '-'; len++); while (str[len] != '\0' && !isspace(str[len]) &&
str[len] != '+' && str[len] != '-')
len++;
/* match token */ /* match token */
found = 0; found = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment