forked from Minki/linux
lib: bitmap: simplify bitmap_parselist
We want len to be the index of the first '\n', or the length of the string if there is no newline. This is a good example of the usefulness of strchrnul(). Use that instead, thus eliminating a branch and a call to strlen(). Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
154f5e38f3
commit
bc5be18280
@ -665,13 +665,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
|
|||||||
|
|
||||||
int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
|
int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
|
||||||
{
|
{
|
||||||
char *nl = strchr(bp, '\n');
|
char *nl = strchrnul(bp, '\n');
|
||||||
int len;
|
int len = nl - bp;
|
||||||
|
|
||||||
if (nl)
|
|
||||||
len = nl - bp;
|
|
||||||
else
|
|
||||||
len = strlen(bp);
|
|
||||||
|
|
||||||
return __bitmap_parselist(bp, len, 0, maskp, nmaskbits);
|
return __bitmap_parselist(bp, len, 0, maskp, nmaskbits);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user