From f3aded3fdb1e19818b05f205b74cd4bff7532811 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 12 Jul 2019 22:28:10 +0100 Subject: include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute Turned out lsblk is passing null as argument to xstrdup(), so fix that and add assert() to make sure promise of not returning null is kept in future. Signed-off-by: Sami Kerola --- include/xalloc.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/xalloc.h b/include/xalloc.h index 0129a85e2..48712a452 100644 --- a/include/xalloc.h +++ b/include/xalloc.h @@ -62,8 +62,7 @@ static inline char __attribute__((warn_unused_result)) __ul_returns_nonnull { char *ret; - if (!str) - return NULL; + assert(str); ret = strdup(str); @@ -77,8 +76,7 @@ xstrndup(const char *str, size_t size) { char *ret; - if (!str) - return NULL; + assert(str); ret = strndup(str, size); -- cgit v1.2.3-55-g7522