From b1ac865abdc017bb824aab452da37e026d3a9a4c Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 3 Jul 2018 11:37:20 +0200 Subject: [PATCH] lib: Downgrade BUG* assertions to work-around crashes BUG() and BUG_ON() didn't use to assert, but only print an error if debugging was enabled. This was hiding a lot of state bugs in drivers, and transforming those into assertions causes crashes. Downgrade the assertion to only print a warning, and hope that those eventually get fixed in the drivers so we can re-enable them. Closes: #77 --- libfprint/fp_internal.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index b4d43e15..3611f76f 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -44,8 +44,14 @@ #define fp_warn g_warning #define fp_err g_error -#define BUG_ON(condition) g_assert(!(condition)) -#define BUG() g_assert_not_reached() +#define BUG_ON(condition) G_STMT_START \ + if (condition) { \ + char *s; \ + s = g_strconcat ("BUG: (", #condition, ")", NULL); \ + g_warning ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ + g_free (s); \ + } G_STMT_END +#define BUG() BUG_ON(1) enum fp_dev_state { DEV_STATE_INITIAL = 0,