aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-08-26 18:19:04 +0200
committerMattias Andrée <maandree@kth.se>2018-08-26 18:19:04 +0200
commit76c4cd89c43e3e2bc7f3f0f58703fcc48a2d6108 (patch)
treec8f538bc24f9623bb084afb999a8b2b9601180de
parentAdd tests (diff)
downloadlibsimple-76c4cd89c43e3e2bc7f3f0f58703fcc48a2d6108.tar.gz
libsimple-76c4cd89c43e3e2bc7f3f0f58703fcc48a2d6108.tar.bz2
libsimple-76c4cd89c43e3e2bc7f3f0f58703fcc48a2d6108.tar.xz
Remove checks impossible situations
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libsimple.h14
1 files 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);\
}\