summaryrefslogtreecommitdiff
path: root/os/xprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/xprintf.c')
-rw-r--r--os/xprintf.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/os/xprintf.c b/os/xprintf.c
index 3b4bb4117..17fea2ec7 100644
--- a/os/xprintf.c
+++ b/os/xprintf.c
@@ -68,18 +68,18 @@
#include <string.h>
#ifdef asprintf
-# undef asprintf
+#undef asprintf
#endif
#ifdef vasprintf
-# undef vasprintf
+#undef vasprintf
#endif
#ifndef va_copy
-# ifdef __va_copy
-# define va_copy __va_copy
-# else
-# error "no working va_copy was found"
-# endif
+#ifdef __va_copy
+#define va_copy __va_copy
+#else
+#error "no working va_copy was found"
+#endif
#endif
/**
@@ -93,7 +93,7 @@
* @return size of allocated buffer, or -1 on error.
*/
int
-Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+Xvasprintf(char **ret, const char *_X_RESTRICT_KYWD format, va_list va)
{
#ifdef HAVE_VASPRINTF
return vasprintf(ret, format, va);
@@ -116,7 +116,7 @@ Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
}
#ifndef HAVE_VASPRINTF
-# define vasprintf Xvasprintf
+#define vasprintf Xvasprintf
#endif
/**
@@ -130,10 +130,11 @@ Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
* @return size of allocated buffer, or -1 on error.
*/
int
-Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+Xasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
+
va_start(va, format);
size = vasprintf(ret, format, va);
va_end(va);
@@ -152,11 +153,12 @@ Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
* @return size of allocated buffer
*/
int
-XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+XNFvasprintf(char **ret, const char *_X_RESTRICT_KYWD format, va_list va)
{
int size = vasprintf(ret, format, va);
+
if ((size == -1) || (*ret == NULL)) {
- FatalError("XNFvasprintf failed: %s", strerror(errno));
+ FatalError("XNFvasprintf failed: %s", strerror(errno));
}
return size;
}
@@ -173,10 +175,11 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
* @return size of allocated buffer
*/
int
-XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+XNFasprintf(char **ret, const char *_X_RESTRICT_KYWD format, ...)
{
int size;
va_list va;
+
va_start(va, format);
size = XNFvasprintf(ret, format, va);
va_end(va);
@@ -190,18 +193,20 @@ Xvprintf(const char *format, va_list va)
char *ret;
if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
+ ret = NULL;
return ret;
}
-char *Xprintf(const char *format, ...)
+char *
+Xprintf(const char *format, ...)
{
char *ret;
va_list va;
+
va_start(va, format);
if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
+ ret = NULL;
va_end(va);
return ret;
}
@@ -216,10 +221,12 @@ XNFvprintf(const char *format, va_list va)
return ret;
}
-char *XNFprintf(const char *format, ...)
+char *
+XNFprintf(const char *format, ...)
{
char *ret;
va_list va;
+
va_start(va, format);
XNFvasprintf(&ret, format, va);
va_end(va);