Patch series "lib: rework bitmap_parse", v5. Similarl to the recently revisited bitmap_parselist(), bitmap_parse() is ineffective and overcomplicated. This series reworks it, aligns its interface with bitmap_parselist() and makes it simpler to use. The series also adds a test for the function and fixes usage of it in cpumask_parse() according to the new design - drops the calculating of length of an input string. bitmap_parse() takes the array of numbers to be put into the map in the BE order which is reversed to the natural LE order for bitmaps. For example, to construct bitmap containing a bit on the position 42, we have to put a line '400,0'. Current implementation reads chunk one by one from the beginning ('400' before '0') and makes bitmap shift after each successful parse. It makes the complexity of the whole process as O(n^2). We can do it in reverse direction ('0' before '400') and avoid shifting, but it requires reverse parsing helpers. This patch (of 7): New function works like strchrnul() with a length limited string.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -62,6 +62,7 @@ extern char * strchr(const char *,int); · 61 unmodified lines | |||
| 62 | #ifndef __HAVE_ARCH_STRCHRNUL | 62 | #ifndef __HAVE_ARCH_STRCHRNUL |
| 63 | extern char * strchrnul(const char *,int); | 63 | extern char * strchrnul(const char *,int); |
| 64 | #endif | 64 | #endif |
| 65 | extern char * strnchrnul(const char *, size_t, int); | ||
| 65 | #ifndef __HAVE_ARCH_STRNCHR | 66 | #ifndef __HAVE_ARCH_STRNCHR |
| 66 | extern char * strnchr(const char *, size_t, int); | 67 | extern char * strnchr(const char *, size_t, int); |
| 67 | #endif | 68 | #endif |