diff options
| author | Mark Brown <broonie@kernel.org> | 2020-10-28 21:36:51 +0000 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2020-10-28 21:36:51 +0000 |
| commit | 3bfd5f422f07a10f485c3f046431783c7c4004f2 (patch) | |
| tree | 7e990a251c825482216a0355177ef80874b3c0cb /lib/string.c | |
| parent | 43b6bf406cd0319e522638f97c9086b7beebaeaa (diff) | |
| parent | 3650b228f83adda7e5ee532e2b90429c03f7b9ec (diff) | |
Merge tag 'v5.10-rc1' into spi-5.10
Linux 5.10-rc1
Diffstat (limited to 'lib/string.c')
| -rw-r--r-- | lib/string.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index 6012c385fb31..4288e0158d47 100644 --- a/lib/string.c +++ b/lib/string.c @@ -272,6 +272,30 @@ ssize_t strscpy_pad(char *dest, const char *src, size_t count) } EXPORT_SYMBOL(strscpy_pad); +/** + * stpcpy - copy a string from src to dest returning a pointer to the new end + * of dest, including src's %NUL-terminator. May overrun dest. + * @dest: pointer to end of string being copied into. Must be large enough + * to receive copy. + * @src: pointer to the beginning of string being copied from. Must not overlap + * dest. + * + * stpcpy differs from strcpy in a key way: the return value is a pointer + * to the new %NUL-terminating character in @dest. (For strcpy, the return + * value is a pointer to the start of @dest). This interface is considered + * unsafe as it doesn't perform bounds checking of the inputs. As such it's + * not recommended for usage. Instead, its definition is provided in case + * the compiler lowers other libcalls to stpcpy. + */ +char *stpcpy(char *__restrict__ dest, const char *__restrict__ src); +char *stpcpy(char *__restrict__ dest, const char *__restrict__ src) +{ + while ((*dest++ = *src++) != '\0') + /* nothing */; + return --dest; +} +EXPORT_SYMBOL(stpcpy); + #ifndef __HAVE_ARCH_STRCAT /** * strcat - Append one %NUL-terminated string to another |
