include/strutils: mark some arguments as non-null

Signed-off-by: Karel Zak <kzak@redhat.com>
pull/1612/head
Karel Zak 7 months ago
parent d65eb48039
commit d57672e2a6
  1. 6
      include/strutils.h

@ -90,7 +90,8 @@ static inline void xstrncpy(char *dest, const char *src, size_t n)
* Use this function to copy string to logs with fixed sizes (wtmp/utmp. ...)
* where string terminator is optional.
*/
static inline void *str2memcpy(void *dest, const char *src, size_t n)
static inline void * __attribute__((nonnull (1)))
str2memcpy(void *dest, const char *src, size_t n)
{
size_t bytes = strlen(src) + 1;
@ -101,7 +102,8 @@ static inline void *str2memcpy(void *dest, const char *src, size_t n)
return dest;
}
static inline char *mem2strcpy(char *dest, const void *src, size_t n, size_t nmax)
static inline char * __attribute__((nonnull (1)))
mem2strcpy(char *dest, const void *src, size_t n, size_t nmax)
{
if (n + 1 > nmax)
n = nmax - 1;

Loading…
Cancel
Save