Replacing prefixcmp(), same purpose, inverted result, so standardize on the kernel variant, to reduce silly differences among tools/ and the kernel sources, making it easier for people to work in both codebases. And then doing: if (strstarts(option, "no-")) Looks clearer than doing: if (!prefixcmp(option, "no-")) To figure out if option starts witn "no-".
Showing the changes to tools/include/linux/string.h (1 of 15 files). Show all
Unified · Split
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | #ifndef _TOOLS_LINUX_STRING_H_ |
| 2 | 2 | #define _TOOLS_LINUX_STRING_H_ |
| 3 | 3 | |
| 4 | − | |
| 5 | 4 | #include <linux/types.h> /* for size_t */ |
| 5 | +#include <string.h> | |
| 6 | 6 | |
| 7 | 7 | void *memdup(const void *src, size_t len); |
| 8 | 8 | |
| @@ -18,6 +18,14 @@ extern size_t strlcpy(char *dest, const char *src, size_t size); · 9 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | char *str_error_r(int errnum, char *buf, size_t buflen); |
| 20 | 20 | |
| 21 | −int prefixcmp(const char *str, const char *prefix); | |
| 21 | +/** | |
| 22 | + * strstarts - does @str start with @prefix? | |
| 23 | + * @str: string to examine | |
| 24 | + * @prefix: prefix to look for. | |
| 25 | + */ | |
| 26 | +static inline bool strstarts(const char *str, const char *prefix) | |
| 27 | +{ | |
| 28 | + return strncmp(str, prefix, strlen(prefix)) == 0; | |
| 29 | +} | |
| 22 | 30 | |
| 23 | 31 | #endif /* _LINUX_STRING_H_ */ |