#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
+#include <printf.h>
#define SD_JOURNAL_SUPPRESS_LOCATION
while (format) {
struct iovec *c;
char *buffer;
+ va_list aq;
if (i >= n) {
n = MAX(i*2, 4);
iov = c;
}
- if (vasprintf(&buffer, format, ap) < 0) {
+ va_copy(aq, ap);
+ if (vasprintf(&buffer, format, aq) < 0) {
+ va_end(aq);
r = -ENOMEM;
goto fail;
}
+ va_end(aq);
+
+ VA_FORMAT_ADVANCE(format, ap);
IOVEC_SET_STRING(iov[i++], buffer);
/* func is initialized from __func__ which is not a macro, but
* a static const char[], hence cannot easily be prefixed with
* CODE_FUNC=, hence let's do it manually here. */
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
zero(iov);
IOVEC_SET_STRING(iov[0], buffer);
goto finish;
}
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(iov[0], file);
IOVEC_SET_STRING(iov[1], line);
niov = alloca(sizeof(struct iovec) * (n + 3));
memcpy(niov, iov, sizeof(struct iovec) * n);
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(niov[n++], file);
IOVEC_SET_STRING(niov[n++], line);
size_t fl;
char *f;
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(iov[0], file);
IOVEC_SET_STRING(iov[1], line);