diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/drm/include/linux/string.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/pci/drm/include/linux/string.h b/sys/dev/pci/drm/include/linux/string.h index b19c465e2a0..f76ddf6f680 100644 --- a/sys/dev/pci/drm/include/linux/string.h +++ b/sys/dev/pci/drm/include/linux/string.h @@ -81,17 +81,21 @@ match_string(const char * const *array, size_t n, const char *str) return -EINVAL; } -/* returns chars written excluding NUL */ static inline ssize_t -strscpy_pad(char *dst, const char *src, size_t dstsize) +strscpy(char *dst, const char *src, size_t dstsize) { ssize_t r; - memset(dst, 0, dstsize); r = strlcpy(dst, src, dstsize); - /* truncation */ - if (r >= dstsize) - r = dstsize - 1; + if (dstsize == 0 || r >= dstsize) + return -E2BIG; return r; } +static inline ssize_t +strscpy_pad(char *dst, const char *src, size_t dstsize) +{ + memset(dst, 0, dstsize); + return strscpy(dst, src, dstsize); +} + #endif |