Replace the open-coded implementation with offset_in_page() to simplify sized_strscpy(). Signed-off-by: Thorsten Blum --- lib/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/string.c b/lib/string.c index 1f9297e9776a..7c72adc7377c 100644 --- a/lib/string.c +++ b/lib/string.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -127,7 +128,7 @@ ssize_t sized_strscpy(char *dest, const char *src, size_t count) * since we don't know if the next page is mapped. */ if ((long)src & (sizeof(long) - 1)) - max = min(PAGE_SIZE - ((long)src & (PAGE_SIZE - 1)), max); + max = min(PAGE_SIZE - offset_in_page(src), max); #else /* If src or dest is unaligned, don't do word-at-a-time. */ if (((long) dest | (long) src) & (sizeof(long) - 1))