fprinte() is like fprintec(), but uses errno instead of an error code.
It is implemented as a macro so that it can read the value in errno
before evaluating any of its arguments, thus not corrupting it.
It also preserves errno so that the error can be printed more than once.
This is useful because we often print to stderr or log_get_logfd(), and
immediately after print to the system log with syslog(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
#include "config.h"
+#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "attr.h"
+// fprinte - FILE* print errno
+#define fprinte(stream, ...) do \
+{ \
+ int e__; \
+ \
+ e__ = errno; \
+ fprintec(stream, e__, __VA_ARGS__); \
+ errno = e__; \
+} while (0)
+
+
format_attr(printf, 3, 4)
inline int fprintec(FILE *restrict stream, int e,
const char *restrict fmt, ...);