From: Jouni Malinen Date: Sat, 6 Dec 2014 22:03:28 +0000 (+0200) Subject: Add os_snprintf_error() helper X-Git-Tag: hostap_2_4~875 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0047306bc9ab7d46e8cc22ff9a3e876c47626473;p=thirdparty%2Fhostap.git Add os_snprintf_error() helper This can be used to check os_snprintf() return value more consistently. Signed-off-by: Jouni Malinen --- diff --git a/src/utils/os.h b/src/utils/os.h index b9247d899..77250d637 100644 --- a/src/utils/os.h +++ b/src/utils/os.h @@ -549,6 +549,12 @@ char * os_strdup(const char *s); #endif /* OS_NO_C_LIB_DEFINES */ +static inline int os_snprintf_error(size_t size, int res) +{ + return res < 0 || (unsigned int) res >= size; +} + + static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size) { if (size && nmemb > (~(size_t) 0) / size)