[PATCH 2/2] string: support overriding strchr/strrchr/strstr macros
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Oct 16 01:56:08 PDT 2024
Architecture code may want to override these functions, e.g.
in the case that they are overridden due to use of libfuzzer.
Add #ifndefs to support that and move up the architecture-specific
header, so the overrides may work.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/string.h | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 4aa11555a005..3b8775c9a57d 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -6,6 +6,10 @@
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */
#include <linux/overflow.h> /* for array_size */
+/*
+ * Include machine specific inline routines
+ */
+#include <asm/string.h>
#ifdef __cplusplus
extern "C" {
@@ -16,27 +20,28 @@ extern char * strsep(char **,const char *);
extern __kernel_size_t strspn(const char *,const char *);
+#ifndef strchr
#define strchr(s, c) ({ \
(typeof(&(s)[0]))(_strchr((s), c)); \
})
+#endif
+#ifndef strrchr
#define strrchr(s, c) ({ \
(typeof(&(s)[0]))(_strrchr((s), c)); \
})
+#endif
+#ifndef strstr
#define strstr(s1, s2) ({ \
(typeof(&(s1)[0]))(_strstr((s1), (s2))); \
})
+#endif
#ifndef __HAVE_ARCH_STRCHRNUL
extern char * strchrnul(const char *,int);
#endif
-/*
- * Include machine specific inline routines
- */
-#include <asm/string.h>
-
#ifndef __HAVE_ARCH_STRCPY
extern char * strcpy(char *,const char *);
#endif
--
2.39.5
More information about the barebox
mailing list