Commit f271df9d authored by Vasily Gorbik's avatar Vasily Gorbik Committed by Heiko Carstens
Browse files

s390/boot: Add sized_strscpy() to enable strscpy() usage



Add a simple sized_strscpy() implementation to allow the use of strscpy()
in the decompressor.

Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent fe201641
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -29,6 +29,18 @@ int strncmp(const char *cs, const char *ct, size_t count)
	return 0;
}

ssize_t sized_strscpy(char *dst, const char *src, size_t count)
{
	size_t len;

	if (count == 0)
		return -E2BIG;
	len = strnlen(src, count - 1);
	memcpy(dst, src, len);
	dst[len] = '\0';
	return src[len] ? -E2BIG : len;
}

void *memset64(uint64_t *s, uint64_t v, size_t count)
{
	uint64_t *xs = s;