From 269d360f3000a13f44715a7b46b4b48b0754f19a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Fri, 25 Feb 2011 21:21:48 -0300 Subject: [PATCH] Some assertions to make the static analyzer happy. Assertions give hints to the static analyzer about code paths where we make assumptions. Used the Clang Static Analyzer. --- src/render.c | 2 ++ src/workspace.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/render.c b/src/render.c index af062c85..499c62a3 100644 --- a/src/render.c +++ b/src/render.c @@ -200,6 +200,7 @@ void render_con(Con *con, bool render_fullscreen) { /* precalculate the sizes to be able to correct rounding errors */ int sizes[children]; if (con->layout == L_DEFAULT && children > 0) { + assert(!TAILQ_EMPTY(&con->nodes_head)); Con *child; int i = 0, assigned = 0; int total = con->orientation == HORIZ ? rect.width : rect.height; @@ -226,6 +227,7 @@ void render_con(Con *con, bool render_fullscreen) { /* FIXME: refactor this into separate functions: */ Con *child; TAILQ_FOREACH(child, &(con->nodes_head), nodes) { + assert(children > 0); /* default layout */ if (con->layout == L_DEFAULT) { diff --git a/src/workspace.c b/src/workspace.c index 2912278d..fa84e204 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -199,7 +199,7 @@ static void workspace_reassign_sticky(Con *con) { * */ void workspace_show(const char *num) { - Con *workspace, *current, *old; + Con *workspace, *current, *old = NULL; workspace = workspace_get(num); @@ -210,6 +210,7 @@ void workspace_show(const char *num) { old = current; current->fullscreen_mode = CF_NONE; } + assert(old != NULL); /* Check if the the currently focused con is on the same Output as the * workspace we chose as 'old'. If not, use the workspace of the currently -- 2.39.5