Skip to contentSkip to conversation

s390/string: Remove strlcat() implementation

PATCH In review Heiko Carstens 3 participants 4 messages May 22 – May 27 s390

lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

PATCH 1/1 s390/string: Remove strlcat() implementation

strlcat() shouldn't be used anymore (see fortify-string.h), and will be deprecated / removed sooner or later [1].

Therefore remove the s390 implementation of strlcat() in favor of the generic variant.

[1] https://lore.kernel.org/all/[email protected]/

---
 arch/s390/include/asm/string.h |  2 --
 arch/s390/lib/string.c         | 26 --------------------------
 2 files changed, 28 deletions(-)
arch/s390/include/asm/string.h +0 -2
index 238e721e5a22..378f85304ef5 100644
@@ -26,7 +26,6 @@ void *memmove(void *dest, const void *src, size_t n);
 #define __HAVE_ARCH_MEMSCAN	/* inline & arch function */
 #define __HAVE_ARCH_STRCAT	/* inline & arch function */
 #define __HAVE_ARCH_STRCMP	/* arch function */
-#define __HAVE_ARCH_STRLCAT	/* arch function */
 #define __HAVE_ARCH_STRLEN	/* inline & arch function */
 #define __HAVE_ARCH_STRNCAT	/* arch function */
 #define __HAVE_ARCH_STRNLEN	/* inline & arch function */
@@ -38,7 +37,6 @@ void *memmove(void *dest, const void *src, size_t n);
 /* Prototypes for non-inlined arch strings functions. */
 int memcmp(const void *s1, const void *s2, size_t n);
 int strcmp(const char *s1, const char *s2);
-size_t strlcat(char *dest, const char *src, size_t n);
 char *strncat(char *dest, const char *src, size_t n);
 char *strstr(const char *s1, const char *s2);
 #endif /* !defined(CONFIG_KASAN) && !defined(CONFIG_KMSAN) */
arch/s390/lib/string.c +0 -26
index 757f58960198..a48e5bb3c15f 100644
@@ -104,32 +104,6 @@ char *strcat(char *dest, const char *src)
 EXPORT_SYMBOL(strcat);
 #endif
 
-/**
- * strlcat - Append a length-limited, %NUL-terminated string to another
- * @dest: The string to be appended to
- * @src: The string to append to it
- * @n: The size of the destination buffer.
- */
-#ifdef __HAVE_ARCH_STRLCAT
-size_t strlcat(char *dest, const char *src, size_t n)
-{
-	size_t dsize = __strend(dest) - dest;
-	size_t len = __strend(src) - src;
-	size_t res = dsize + len;
-
-	if (dsize < n) {
-		dest += dsize;
-		n -= dsize;
-		if (len >= n)
-			len = n - 1;
-		dest[len] = '\0';
-		memcpy(dest, src, len);
-	}
-	return res;
-}
-EXPORT_SYMBOL(strlcat);
-#endif
-
 /**
  * strncat - Append a length-limited, %NUL-terminated string to another
  * @dest: The string to be appended to
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Heiko Carstens

strlcat() shouldn't be used anymore (see fortify-string.h), and will be deprecated / removed sooner or later [1].

Therefore remove the s390 implementation of strlcat() in favor of the generic variant.

Quoted 7 lines

[1] https://lore.kernel.org/all/[email protected]/

---
 arch/s390/include/asm/string.h |  2 --
 arch/s390/lib/string.c         | 26 --------------------------
 2 files changed, 28 deletions(-)

and pushed.

Thanks!

#2 lore raw
In reply to Heiko Carstens
Quoted 3 lines · On Fri, 22 May 2026 16:31:11 +0200 Heiko Carstens <[email protected]> wrote:

strlcat() shouldn't be used anymore (see fortify-string.h), and will be deprecated / removed sooner or later [1].

....

Quoted 1 line

#define __HAVE_ARCH_STRCAT /* inline & arch function */

...

Quoted 1 line

#define __HAVE_ARCH_STRNCAT /* arch function */

Those two should probably have gone first ...

-- David

author maintainer
#3 lore raw
Quoted 6 lines · David Laight
Quoted 3 lines · On Fri, 22 May 2026 16:31:11 +0200 Heiko Carstens <[email protected]> wrote:

strlcat() shouldn't be used anymore (see fortify-string.h), and will be deprecated / removed sooner or later [1].

Quoted 6 lines

....

Quoted 1 line

#define __HAVE_ARCH_STRCAT /* inline & arch function */

...

Quoted 1 line

#define __HAVE_ARCH_STRNCAT /* arch function */

Those two should probably have gone first ...

Yes, except that we need strcat() for the boot code - there we cannot use the generic variant. Of course it would be possible to copy the existing strcat() implementation to the boot code, rename it to e.g. strconcatenate(), and strcat()/strncat() would be gone, at least grep wise :)