From 76c4cd89c43e3e2bc7f3f0f58703fcc48a2d6108 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 26 Aug 2018 18:19:04 +0200 Subject: Remove checks impossible situations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libsimple.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libsimple.h b/libsimple.h index e3064e3..371cd83 100644 --- a/libsimple.h +++ b/libsimple.h @@ -639,16 +639,11 @@ int libsimple_vasprintf(char **, const char *, va_list); const char *__f = (__fmt);\ char *__ret = NULL;\ int __r = snprintf(NULL, 0, __f, __VA_ARGS__);\ - if (__r < 0) {\ - __ret;\ - } else if ((size_t)__r == SIZE_MAX) {\ - errno = ENOMEM;\ - __ret;\ - } else {\ + if (__r >= 0) {\ __ret = alloca((size_t)__r + 1);\ sprintf(__ret, __f, __VA_ARGS__);\ - __ret;\ }\ + __ret;\ }) # ifndef asprintfa # define asprintfa(...) libsimple_asprintfa(__VA_ARGS__) @@ -666,10 +661,7 @@ int libsimple_vasprintf(char **, const char *, va_list); int __r;\ va_copy(__a2, __a);\ __r = vsnprintf(NULL, 0, __f, __a);\ - if (__r < 0);\ - else if ((size_t)__r == SIZE_MAX) {\ - errno = ENOMEM;\ - } else {\ + if (__r >= 0) {\ __ret = alloca((size_t)__r + 1);\ vsprintf(__ret, __f, __a2);\ }\ -- cgit v1.2.3-70-g09d2