diff --git a/config.c b/config.c index 04d563eb..56acb0cf 100644 --- a/config.c +++ b/config.c @@ -1230,7 +1230,7 @@ argv_compare(char *const *argv1, char *const *argv2) return ret; } - xassert(false); + BUG("unexpected loop break"); return 1; } diff --git a/fdm.c b/fdm.c index 3394f10c..34d0fbff 100644 --- a/fdm.c +++ b/fdm.c @@ -105,16 +105,12 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data) #if defined(_DEBUG) int flags = fcntl(fd, F_GETFL); if (!(flags & O_NONBLOCK)) { - LOG_ERR("FD=%d is in blocking mode", fd); - xassert(false); - return false; + BUG("FD=%d is in blocking mode", fd); } tll_foreach(fdm->fds, it) { if (it->item->fd == fd) { - LOG_ERR("FD=%d already registered", fd); - xassert(false); - return false; + BUG("FD=%d already registered", fd); } } #endif @@ -251,7 +247,7 @@ hook_priority_to_list(struct fdm *fdm, enum fdm_hook_priority priority) case FDM_HOOK_PRIORITY_HIGH: return &fdm->hooks_high; } - xassert(false); + BUG("unhandled priority type"); return NULL; } diff --git a/input.c b/input.c index 79368270..64ab2065 100644 --- a/input.c +++ b/input.c @@ -209,7 +209,7 @@ execute_binding(struct seat *seat, struct terminal *term, break; default: - xassert(false); + BUG("Unhandled action type"); success = false; break; } @@ -325,7 +325,7 @@ execute_binding(struct seat *seat, struct terminal *term, return true; case BIND_ACTION_COUNT: - xassert(false); + BUG("Invalid action type"); return false; } @@ -1150,7 +1150,7 @@ xcursor_for_csd_border(struct terminal *term, int x, int y) else if (term->active_surface == TERM_SURF_BORDER_TOP) return XCURSOR_TOP_SIDE; else if (term->active_surface == TERM_SURF_BORDER_BOTTOM) return XCURSOR_BOTTOM_SIDE; else { - xassert(false); + BUG("Unreachable"); return NULL; } } @@ -1225,7 +1225,7 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, break; case TERM_SURF_NONE: - xassert(false); + BUG("Invalid surface type"); break; } } @@ -1806,7 +1806,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, } case TERM_SURF_NONE: - xassert(false); + BUG("Invalid surface type"); break; } diff --git a/render.c b/render.c index 71d54f4c..026f176f 100644 --- a/render.c +++ b/render.c @@ -1367,11 +1367,10 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) case CSD_SURF_CLOSE: return (struct csd_data){term->width - 1 * button_width, 0, button_close_width, title_height}; case CSD_SURF_COUNT: - xassert(false); - return (struct csd_data){0}; + break; } - xassert(false); + BUG("Invalid csd_surface type"); return (struct csd_data){0}; } @@ -1643,7 +1642,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) break; default: - xassert(false); + BUG("unhandled surface type: %u", (unsigned)surf_idx); break; } @@ -1670,7 +1669,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) break; default: - xassert(false); + BUG("unhandled surface type: %u", (unsigned)surf_idx); break; } @@ -1879,7 +1878,7 @@ render_scrollback_position(struct terminal *term) int surf_top = 0; switch (term->conf->scrollback.indicator.position) { case SCROLLBACK_INDICATOR_POSITION_NONE: - xassert(false); + BUG("Invalid scrollback indicator position type"); return; case SCROLLBACK_INDICATOR_POSITION_FIXED: diff --git a/search.c b/search.c index 4fde8a92..d7939219 100644 --- a/search.c +++ b/search.c @@ -785,11 +785,11 @@ execute_binding(struct seat *seat, struct terminal *term, return true; case BIND_ACTION_SEARCH_COUNT: - xassert(false); + BUG("Invalid action type"); return true; } - xassert(false); + BUG("Unhandled action type"); return false; } diff --git a/selection.c b/selection.c index 90c6c392..cb625541 100644 --- a/selection.c +++ b/selection.c @@ -195,11 +195,10 @@ foreach_selected( return; case SELECTION_NONE: - xassert(false); - return; + break; } - xassert(false); + BUG("Invalid selection kind"); } static bool @@ -426,7 +425,7 @@ selection_start(struct terminal *term, int col, int row, break; case SELECTION_NONE: - xassert(false); + BUG("Invalid selection kind"); break; } @@ -728,7 +727,7 @@ selection_update(struct terminal *term, int col, int row) break; case SELECTION_NONE: - xassert(false); + BUG("Invalid selection kind"); break; } @@ -861,7 +860,7 @@ selection_extend_normal(struct terminal *term, int col, int row, case SELECTION_BLOCK: case SELECTION_NONE: - xassert(false); + BUG("Invalid selection kind in this context"); break; } @@ -963,7 +962,7 @@ selection_extend(struct seat *seat, struct terminal *term, switch (term->selection.kind) { case SELECTION_NONE: - xassert(false); + BUG("Invalid selection kind"); return; case SELECTION_CHAR_WISE: diff --git a/slave.c b/slave.c index 29ad92f5..432e21ff 100644 --- a/slave.c +++ b/slave.c @@ -18,6 +18,7 @@ #include "log.h" #include "debug.h" +#include "macros.h" #include "terminal.h" #include "tokenize.h" #include "xmalloc.h" @@ -143,7 +144,7 @@ emit_notifications(int fd, const user_notifications_t *notifications) emit_notifications_of_kind(fd, notifications, USER_NOTIFICATION_DEPRECATED); } -static void +static noreturn void slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell, const user_notifications_t *notifications) { @@ -316,7 +317,7 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv, setenv("SHELL", shell_argv[0], 1); slave_exec(ptmx, shell_argv, fork_pipe[1], login_shell, notifications); - xassert(false); + BUG("Unexpected return from slave_exec()"); break; default: { diff --git a/terminal.c b/terminal.c index 8e1e1841..c080c0c4 100644 --- a/terminal.c +++ b/terminal.c @@ -97,8 +97,7 @@ data_to_slave(struct terminal *term, const void *data, size_t len, return false; } - /* Shouldn't get here */ - xassert(false); + BUG("Unexpected async_write() return value"); return false; } @@ -1931,7 +1930,7 @@ term_row_rel_to_abs(const struct terminal *term, int row) return min(row + term->scroll_region.start, term->scroll_region.end - 1); } - xassert(false); + BUG("Invalid cursor_origin value"); return -1; } @@ -2483,7 +2482,7 @@ term_mouse_down(struct terminal *term, int button, int row, int col, case MOUSE_X10: /* Never enabled */ - xassert(false && "unimplemented"); + BUG("X10 mouse mode not implemented"); break; } } @@ -2525,7 +2524,7 @@ term_mouse_up(struct terminal *term, int button, int row, int col, case MOUSE_X10: /* Never enabled */ - xassert(false && "unimplemented"); + BUG("X10 mouse mode not implemented"); break; } } @@ -2572,7 +2571,7 @@ term_mouse_motion(struct terminal *term, int button, int row, int col, case MOUSE_X10: /* Never enabled */ - xassert(false && "unimplemented"); + BUG("X10 mouse mode not implemented"); break; } }