History

include/linux/cpumask.h: fix double string traverse in cpumask_parse

cpumask_parse() finds first occurrence of either or strchr() and strlen(). We can do it better with a single call of strchrnul(). [akpm@linux-foundation.org: remove unneeded cast] Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com Signed-off-by: Yury Norov <ynorov@marvell.com> Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Yury Norov committed 7 years ago

Commit 3713a4e1 parent 4e7301e1 file · +1 −2Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/cpumask.h+1−2
@@ -633,8 +633,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len, · 632 unmodified lines
633 */633 */
634static inline int cpumask_parse(const char *buf, struct cpumask *dstp)634static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
635{635{
636 char *nl = strchr(buf, '\n');636 unsigned int len = strchrnul(buf, '\n') - buf;
637 unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
638 637
639 return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);638 return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
640}639}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t