[PATCH v2 3/9] lib/string.c: drop pointless __HAVE_ARCH_STRDUP
Rasmus Villemoes
ravi at prevas.dk
Tue Apr 21 09:54:33 CEST 2026
There has never been an arch-specific optimized implementation of
str[n]dup, nor is there likely to ever be one, because unlike their
cousins strlen(), strcpy() and similar that simply read/write the
src/dst, the dup functions by definition involve memory allocation. So
drop this irrelevant cpp guard.
Reviewed-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
---
include/linux/string.h | 3 +--
lib/string.c | 2 --
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/linux/string.h b/include/linux/string.h
index 9e47fe01c16..a28150fa578 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -101,10 +101,9 @@ size_t strcspn(const char *s, const char *reject);
# define strndup sandbox_strndup
#endif
-#ifndef __HAVE_ARCH_STRDUP
extern char * strdup(const char *);
extern char * strndup(const char *, size_t);
-#endif
+
#ifndef __HAVE_ARCH_STRSWAB
extern char * strswab(const char *);
#endif
diff --git a/lib/string.c b/lib/string.c
index c2813e0f854..2c1baa568b9 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -343,7 +343,6 @@ size_t strcspn(const char *s, const char *reject)
}
#endif
-#ifndef __HAVE_ARCH_STRDUP
char * strdup(const char *s)
{
char *new;
@@ -379,7 +378,6 @@ char * strndup(const char *s, size_t n)
return new;
}
-#endif
#ifndef __HAVE_ARCH_STRSPN
/**
--
2.53.0
More information about the U-Boot
mailing list