From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] string: support overriding strchr/strrchr/strstr macros
Date: Wed, 16 Oct 2024 10:56:08 +0200 [thread overview]
Message-ID: <20241016085608.3962813-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241016085608.3962813-1-a.fatoum@pengutronix.de>
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@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
next prev parent reply other threads:[~2024-10-16 8:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 8:56 [PATCH 1/2] string: add strlcat support Ahmad Fatoum
2024-10-16 8:56 ` Ahmad Fatoum [this message]
2024-10-18 8:52 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241016085608.3962813-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox