From 835b293d35a209d38047126443d41fa7090daa4c Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 19 Jun 2017 21:20:57 +0200 Subject: Use our own variant of 'assert' and 'assert_perror'. Our variants print stack traces on failures. This will make locating errors much easier. --- console-client/console.c | 2 +- console-client/ncursesw.c | 16 ++++++++-------- console-client/pc-kbd.c | 8 ++++---- console-client/vga-dynacolor.c | 10 +++++----- console-client/vga-dynafont.c | 6 +++--- console-client/vga-support.c | 4 ++-- console-client/vga.c | 2 +- console-client/xkb/compose.c | 6 +++--- console-client/xkb/kstoucs.c | 4 ++-- console-client/xkb/xkbtimer.c | 4 ++-- 10 files changed, 31 insertions(+), 31 deletions(-) (limited to 'console-client') diff --git a/console-client/console.c b/console-client/console.c index 2fa05339..5335156b 100644 --- a/console-client/console.c +++ b/console-client/console.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #if HAVE_DAEMON diff --git a/console-client/ncursesw.c b/console-client/ncursesw.c index 881acad7..8e8962fd 100644 --- a/console-client/ncursesw.c +++ b/console-client/ncursesw.c @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include @@ -324,7 +324,7 @@ input_loop (void *unused) console_exit (); break; case 23: /* ^W */ - assert (size < 100); + assert_backtrace (size < 100); buf[size++] = ret; break; case '1': @@ -397,7 +397,7 @@ input_loop (void *unused) { if (keycodes[i].cons) { - assert (size + assert_backtrace (size < 101 - strlen (keycodes[i].cons)); strcpy (&buf[size], keycodes[i].cons); size += strlen (keycodes[i].cons); @@ -408,7 +408,7 @@ input_loop (void *unused) } if (!found) { - assert (size < 100); + assert_backtrace (size < 100); buf[size++] = ret; } break; @@ -472,7 +472,7 @@ mvwputsn (conchar_t *str, size_t len, off_t x, off_t y) { printf ("setcchar failed: %s\n", strerror (errno)); printf ("[%lc]\n", wch[0]); - assert (!"Do something if setcchar fails."); + assert_backtrace (!"Do something if setcchar fails."); } #endif ret = wadd_wch (conspad, &chr); @@ -481,7 +481,7 @@ mvwputsn (conchar_t *str, size_t len, off_t x, off_t y) { printf ("add_wch failed: %i, %s\n", ret, strerror (errno)); printf ("[%lc]\n", wch[0]); - assert (!"Do something if add_wchr fails."); + assert_backtrace (!"Do something if add_wchr fails."); } #endif } @@ -505,7 +505,7 @@ static error_t ncursesw_set_cursor_pos (void *handle, uint32_t col, uint32_t row) { pthread_mutex_lock (&ncurses_lock); - assert (current_width && current_height); + assert_backtrace (current_width && current_height); if (autoscroll) { /* Autoscroll to the right. */ @@ -569,7 +569,7 @@ static error_t ncursesw_scroll (void *handle, int delta) { /* XXX We don't support scrollback for now. */ - assert (delta >= 0); + assert_backtrace (delta >= 0); pthread_mutex_lock (&ncurses_lock); idlok (conspad, TRUE); diff --git a/console-client/pc-kbd.c b/console-client/pc-kbd.c index 2fc7608f..85f3a5cd 100644 --- a/console-client/pc-kbd.c +++ b/console-client/pc-kbd.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include -#include +#include #include #include #include @@ -1084,12 +1084,12 @@ input_loop (void *unused) if (!sc_to_kc[sc][modifier][0]) { /* Special meaning, emit NUL. */ - assert (size < 100); + assert_backtrace (size < 100); buf[size++] = '\0'; } else { - assert (size + assert_backtrace (size < 101 - strlen(sc_to_kc[sc][modifier])); strcpy (&buf[size], sc_to_kc[sc][modifier]); size += strlen (sc_to_kc[sc][modifier]); @@ -1162,7 +1162,7 @@ input_loop (void *unused) { if (modifier >= 0 && sc_x1_to_kc[sc][modifier]) { - assert (size < 101 - strlen(sc_x1_to_kc[sc][modifier])); + assert_backtrace (size < 101 - strlen(sc_x1_to_kc[sc][modifier])); strcpy (&buf[size], sc_x1_to_kc[sc][modifier]); size += strlen (sc_x1_to_kc[sc][modifier]); } diff --git a/console-client/vga-dynacolor.c b/console-client/vga-dynacolor.c index 9289e1eb..ef952478 100644 --- a/console-client/vga-dynacolor.c +++ b/console-client/vga-dynacolor.c @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -#include +#include #include @@ -290,18 +290,18 @@ dynacolor_replace_colors (dynacolor_t *dc, } } - assert (res_bgcol >= 0); + assert_backtrace (res_bgcol >= 0); new_bgcol = pref[bgcol][i]; } if (fgcol == bgcol) { - assert (res_fgcol == -1); + assert_backtrace (res_fgcol == -1); /* Acquire another reference. */ res_fgcol = dynacolor_lookup (*dc, new_bgcol); } else - assert (res_fgcol != res_bgcol); + assert_backtrace (res_fgcol != res_bgcol); if (res_fgcol == -1) { @@ -315,7 +315,7 @@ dynacolor_replace_colors (dynacolor_t *dc, break; } } - assert (res_fgcol >= 0); + assert_backtrace (res_fgcol >= 0); } *r_fgcol = res_fgcol; *r_bgcol = res_bgcol; diff --git a/console-client/vga-dynafont.c b/console-client/vga-dynafont.c index 2cee47ed..c6627721 100644 --- a/console-client/vga-dynafont.c +++ b/console-client/vga-dynafont.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include -#include +#include #include #include #include @@ -848,7 +848,7 @@ dynafont_lookup_internal (dynafont_t df, bdf_font_t font, } while (pos != start_pos); - assert (found); + assert_backtrace (found); df->vga_font_free_indices_lgc--; df->vga_font_last_free_index_lgc = pos; } @@ -872,7 +872,7 @@ dynafont_lookup_internal (dynafont_t df, bdf_font_t font, } while (pos != start_pos); - assert (found); + assert_backtrace (found); df->vga_font_free_indices--; df->vga_font_last_free_index = pos; } diff --git a/console-client/vga-support.c b/console-client/vga-support.c index 3a2d7586..32ede46d 100644 --- a/console-client/vga-support.c +++ b/console-client/vga-support.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ #include -#include +#include #include #include #include @@ -225,7 +225,7 @@ vga_read_write_font_buffer (int write, int buffer, int index, char saved_gfx_misc; int offset = buffer * VGA_FONT_SIZE + index * VGA_FONT_HEIGHT; - assert (offset >= 0 && offset + datalen <= VGA_VIDEO_MEM_LENGTH); + assert_backtrace (offset >= 0 && offset + datalen <= VGA_VIDEO_MEM_LENGTH); /* Select plane 2 for sequential writing. You might think it is not necessary for reading, but it is. Likewise for read settings diff --git a/console-client/vga.c b/console-client/vga.c index 2d74aae3..9d751a7f 100644 --- a/console-client/vga.c +++ b/console-client/vga.c @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ -#include +#include #include #include #include diff --git a/console-client/xkb/compose.c b/console-client/xkb/compose.c index fb3f07ca..17f30014 100644 --- a/console-client/xkb/compose.c +++ b/console-client/xkb/compose.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include /* Tokens that can be recognised by the scanner. */ enum tokentype @@ -427,8 +427,8 @@ map_iterate(const char *map_path, map_callback action, void *context) size_t buffer_size = 0; size_t line_length = 0; - assert (map_path != NULL); - assert (action != NULL); + assert_backtrace (map_path != NULL); + assert_backtrace (action != NULL); map = fopen (map_path, "r"); diff --git a/console-client/xkb/kstoucs.c b/console-client/xkb/kstoucs.c index eb47bdeb..59af1e9f 100644 --- a/console-client/xkb/kstoucs.c +++ b/console-client/xkb/kstoucs.c @@ -1,4 +1,4 @@ -#include +#include struct ksmap { int keysym; @@ -13,7 +13,7 @@ find_ucs (int keysym, struct ksmap *first, struct ksmap *last) { struct ksmap *middle = first + (last - first) / 2; - assert (first <= last); + assert_backtrace (first <= last); if (middle->keysym == keysym) return middle->ucs; /* base case: needle found. */ diff --git a/console-client/xkb/xkbtimer.c b/console-client/xkb/xkbtimer.c index 24791e9e..28e1c685 100644 --- a/console-client/xkb/xkbtimer.c +++ b/console-client/xkb/xkbtimer.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include "xkb.h" #include @@ -123,7 +123,7 @@ key_timing (void *handle) switch (per_key_timers[current_key].enable_status) { case timer_stopped: - assert ("Stopped timer triggered timer event\n"); + assert_backtrace ("Stopped timer triggered timer event\n"); break; case timer_slowkeys: per_key_timers[current_key].enable_timer.expires -- cgit v1.2.3