basic/log: assert that %m is not used when error is not set

This is only done in developer mode. It is a pretty rare occurence that we
make this kind of mistake. And even if it happens, the result is just a misleading
error message. So let's only do the check in non-release builds.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-04-14 16:19:54 +02:00
parent cbe97b9c92
commit 63275a7032
+7 -1
View File
@@ -4,6 +4,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include "macro.h"
@@ -197,7 +198,12 @@ void log_assert_failed_return(
_e < 0 ? _e : -EIO; \
})
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__)
#define log_full(level, fmt, ...) \
({ \
if (BUILD_MODE_DEVELOPER) \
assert(!strstr(fmt, "%m")); \
(void) log_full_errno((level), 0, fmt, ##__VA_ARGS__); \
})
int log_emergency_level(void);