]> git.mdlowis.com Git - proto/labwc.git/commitdiff
s/BUG_ON/assert/
authorJohan Malm <jgm323@gmail.com>
Mon, 28 Sep 2020 19:53:59 +0000 (20:53 +0100)
committerJohan Malm <jgm323@gmail.com>
Mon, 28 Sep 2020 19:53:59 +0000 (20:53 +0100)
include/common/bug-on.h [deleted file]
include/labwc.h
src/config/rcxml.c
src/deco.c
src/desktop.c
src/xbm/parse.c
src/xdg.c
src/xwayland.c

diff --git a/include/common/bug-on.h b/include/common/bug-on.h
deleted file mode 100644 (file)
index 1b25c80..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __LABWC_BUG_ON_H
-#define __LABWC_BUG_ON_H
-
-/**
- * BUG_ON - assert() without abort()
- * @condition - expression to be evaluated
- */
-#define BUG_ON(condition)                                             \
-       do {                                                          \
-               if ((condition) != 0) {                               \
-                       fprintf(stderr, "Badness in %s() at %s:%d\n", \
-                               __func__, __FILE__, __LINE__);        \
-               }                                                     \
-       } while (0)
-
-#endif /* __LABWC_BUG_ON_H */
index 3675714d10665b3f979a1ef80759e86c59feaa18..b801e246b8492ceab1d19a9538280aef026d8e4a 100644 (file)
@@ -28,7 +28,6 @@
 #include <wlr/xwayland.h>
 #include <xkbcommon/xkbcommon.h>
 
-#include "common/bug-on.h"
 #include "common/log.h"
 #include "config/keybind.h"
 #include "config/rcxml.h"
index bc26aa557e4bdfe914f2b780bfd0d4ac6ba753ab..0a62c386e82286e145bc7cf3c601a16f2a89e86e 100644 (file)
@@ -1,4 +1,5 @@
 #define _POSIX_C_SOURCE 200809L
+#include <assert.h>
 #include <ctype.h>
 #include <fcntl.h>
 #include <libxml/parser.h>
@@ -10,7 +11,6 @@
 #include <unistd.h>
 #include <wayland-server-core.h>
 
-#include "common/bug-on.h"
 #include "common/dir.h"
 #include "common/font.h"
 #include "common/log.h"
@@ -51,7 +51,7 @@ fill_keybind(char *nodename, char *content)
                current_keybind = keybind_create(content);
        }
        /* We expect <keybind key=""> to come first */
-       BUG_ON(!current_keybind);
+       assert(current_keybind);
        if (!strcmp(nodename, "name.action")) {
                current_keybind->action = strdup(content);
        } else if (!strcmp(nodename, "command.action")) {
index 4890e3f16d3b50fdb113a821419610fe5798614d..30cf113f07a4e2dbdb02b4d6f3b0644ff71377ab 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright Johan Malm 2020
  */
 
+#include <assert.h>
 #include "config/rcxml.h"
 #include "labwc.h"
 #include "theme/theme.h"
@@ -39,7 +40,7 @@ struct wlr_box
 deco_box(struct view *view, enum deco_part deco_part)
 {
        struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
-       BUG_ON(!view);
+       assert(view);
        switch (deco_part) {
        case LAB_DECO_BUTTON_CLOSE:
                box.width = rc.title_height;
index 7d08de29a9f80083e7914873c0e9c46f162981d2..c3937d53110c5a79dca1ec73fcdd5265c3d5989b 100644 (file)
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include "labwc.h"
 
 static void
@@ -169,7 +170,7 @@ has_mapped_view(struct wl_list *wl_list)
 struct view *
 desktop_next_mapped_view(struct view *current)
 {
-       BUG_ON(!current);
+       assert(current);
        struct server *server = current->server;
        if (!has_mapped_view(&server->views)) {
                return NULL;
@@ -183,7 +184,7 @@ desktop_next_mapped_view(struct view *current)
 void
 desktop_focus_next_mapped_view(struct view *current)
 {
-       BUG_ON(!current);
+       assert(current);
        struct view *view = desktop_next_mapped_view(current);
        desktop_focus_view(view);
 }
index ce733b9d3a1f3487fe38fcd0f32fd1e33c365483..5589ae2652189696dc20539783232c5cee1bb0c0 100644 (file)
@@ -5,13 +5,13 @@
  */
 
 #define _POSIX_C_SOURCE 200809L
+#include <assert.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "common/bug-on.h"
 #include "xbm/parse.h"
 
 static uint32_t color;
@@ -94,7 +94,7 @@ parse_xbm_builtin(const char *button, int size)
 {
        struct pixmap pixmap = { 0 };
 
-       BUG_ON(size > LABWC_BUILTIN_ICON_MAX_SIZE);
+       assert(size <= LABWC_BUILTIN_ICON_MAX_SIZE);
        pixmap.width = size;
        pixmap.height = size;
 
index 928595016db600572a31fe019363c539b4d96f02..21747e01e9736e22618a49d3e85f1bed818df7ba 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include "labwc.h"
 
 struct xdg_deco {
@@ -73,7 +74,7 @@ static void
 handle_commit(struct wl_listener *listener, void *data)
 {
        struct view *view = wl_container_of(listener, view, commit);
-       BUG_ON(!view->surface);
+       assert(view->surface);
        view->w = view->surface->current.width;
        view->h = view->surface->current.height;
 }
index 2c2565223ab9053fc364f199fad995386b1db153..ed11b7bfed73c5d9f55f6f8391e3a69265badbf3 100644 (file)
@@ -1,10 +1,11 @@
+#include <assert.h>
 #include "labwc.h"
 
 static void
 handle_commit(struct wl_listener *listener, void *data)
 {
        struct view *view = wl_container_of(listener, view, commit);
-       BUG_ON(!view->surface);
+       assert(view->surface);
 
        /* Must receive commit signal before accessing surface->current* */
        view->w = view->surface->current.width;