Messages in this thread Patch in this message | | | From | Baskov Evgeniy <> | Subject | [PATCH v3 1/2] x86: Add strlcat() to compressed kernel | Date | Thu, 5 May 2022 13:32:23 +0300 |
| |
strlcat() simplifies the code of command line concatenation and reduces the probability of mistakes.
Signed-off-by: Baskov Evgeniy <baskov@ispras.ru>
diff --git a/arch/x86/boot/compressed/string.c b/arch/x86/boot/compressed/string.c index 81fc1eaa3229..b0635539b6f6 100644 --- a/arch/x86/boot/compressed/string.c +++ b/arch/x86/boot/compressed/string.c @@ -40,6 +40,21 @@ static void *____memcpy(void *dest, const void *src, size_t n) } #endif +size_t strlcat(char *dest, const char *src, size_t count) +{ + size_t dsize = strlen(dest); + size_t len = strlen(src); + size_t res = dsize + len; + + dest += dsize; + count -= dsize; + if (len >= count) + len = count-1; + memcpy(dest, src, len); + dest[len] = 0; + return res; +} + void *memset(void *s, int c, size_t n) { int i; -- 2.36.0
| |