From eb3b1ec5f1ccdeccae237fa8c8662e795bb7fad7 Mon Sep 17 00:00:00 2001 From: Jerzi Kaminsky Date: Sun, 16 Apr 2017 10:30:17 +0300 Subject: Fix variadic forwarding in sway_assert _sway_assert is a variadic function which tries to delegate to another variadic function. This requires a vprintf-style variant of the delegate. https://stackoverflow.com/a/150616 --- include/log.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/log.h b/include/log.h index 2c4150e4..60b3763b 100644 --- a/include/log.h +++ b/include/log.h @@ -28,6 +28,9 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const #define sway_log(VERBOSITY, FMT, ...) \ _sway_log(__FILE__, __LINE__, VERBOSITY, FMT, ##__VA_ARGS__) +#define sway_vlog(VERBOSITY, FMT, VA_ARGS) \ + _sway_vlog(__FILE__, __LINE__, VERBOSITY, FMT, VA_ARGS) + void error_handler(int sig); #endif -- cgit v1.2.3-54-g00ecf From 709b53bd4347ee0ba4925ae02a5f89ca15f380c8 Mon Sep 17 00:00:00 2001 From: Jerzi Kaminsky Date: Sun, 16 Apr 2017 12:07:43 +0300 Subject: Fix location reported by sway_assert --- common/log.c | 4 ++-- include/log.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/common/log.c b/common/log.c index 23b756eb..8e5b71f9 100644 --- a/common/log.c +++ b/common/log.c @@ -142,14 +142,14 @@ void sway_log_errno(log_importance_t verbosity, char* format, ...) { } } -bool _sway_assert(bool condition, const char* format, ...) { +bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) { if (condition) { return true; } va_list args; va_start(args, format); - sway_vlog(L_ERROR, format, args); + _sway_vlog(filename, line, L_ERROR, format, args); va_end(args); #ifndef NDEBUG diff --git a/include/log.h b/include/log.h index 60b3763b..32981b62 100644 --- a/include/log.h +++ b/include/log.h @@ -19,9 +19,9 @@ void sway_log_colors(int mode); void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3))); void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); -bool _sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3))); +bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5))); #define sway_assert(COND, FMT, ...) \ - _sway_assert(COND, "%s:" FMT, __PRETTY_FUNCTION__, ##__VA_ARGS__) + _sway_assert(COND, __FILE__, __LINE__, "%s:" FMT, __PRETTY_FUNCTION__, ##__VA_ARGS__) void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,4,5))); -- cgit v1.2.3-54-g00ecf