Fix location reported by sway_assert

This commit is contained in:
Jerzi Kaminsky 2017-04-16 12:07:43 +03:00
parent eb3b1ec5f1
commit 709b53bd43
2 changed files with 4 additions and 4 deletions

View file

@ -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) { if (condition) {
return true; return true;
} }
va_list args; va_list args;
va_start(args, format); va_start(args, format);
sway_vlog(L_ERROR, format, args); _sway_vlog(filename, line, L_ERROR, format, args);
va_end(args); va_end(args);
#ifndef NDEBUG #ifndef NDEBUG

View file

@ -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_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2))); 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, ...) \ #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))); void _sway_log(const char *filename, int line, log_importance_t verbosity, const char* format, ...) __attribute__((format(printf,4,5)));