conmon: Use strerror(errno) instead of %m
Avoid: $ make clean && make CFLAGS=-Wpedantic 2>&1 | head -n5 rm -f conmon.o cmsg.o ../bin/conmon cc -Wpedantic -std=c99 -Os -Wall -Wextra -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -c -o conmon.o conmon.c conmon.c: In function ‘write_k8s_log’: conmon.c:32:19: warning: ISO C does not support the ‘%m’ gnu_printf format [-Wformat=] fprintf(stderr, "[conmon:e]: %s %m\n", s); \ ^ from printf(3) [1]: m (Glibc extension; supported by uClibc and musl.) Print output of strerror(errno). No argument is required. strerror, on the other hand, is in POSIX [2]. [1]: http://man7.org/linux/man-pages/man3/printf.3.html [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html Signed-off-by: W. Trevor King <wking@tremily.us>
This commit is contained in:
parent
9583581280
commit
f67d6ed25c
|
@ -27,18 +27,18 @@
|
|||
|
||||
#include "cmsg.h"
|
||||
|
||||
#define pexit(s) \
|
||||
do { \
|
||||
fprintf(stderr, "[conmon:e]: %s %m\n", s); \
|
||||
syslog(LOG_ERR, "conmon <error>: %s %m\n", s); \
|
||||
exit(EXIT_FAILURE); \
|
||||
#define pexit(s) \
|
||||
do { \
|
||||
fprintf(stderr, "[conmon:e]: %s %s\n", s, strerror(errno)); \
|
||||
syslog(LOG_ERR, "conmon <error>: %s %s\n", s, strerror(errno)); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
#define pexitf(fmt, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "[conmon:e]: " fmt " %m\n", ##__VA_ARGS__); \
|
||||
syslog(LOG_ERR, "conmon <error>: " fmt ": %m\n", ##__VA_ARGS__); \
|
||||
exit(EXIT_FAILURE); \
|
||||
#define pexitf(fmt, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "[conmon:e]: " fmt " %s\n", ##__VA_ARGS__, strerror(errno)); \
|
||||
syslog(LOG_ERR, "conmon <error>: " fmt ": %s\n", ##__VA_ARGS__, strerror(errno)); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} while (0)
|
||||
|
||||
#define nexit(s) \
|
||||
|
|
Loading…
Reference in New Issue