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:
+7
-1
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user