From a375e58bb872feea4773a8791d68fbd6303a7000 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 3 May 2015 17:23:44 +0100 Subject: Silence incorrect warning from gcc 4.9 This makes the box_move_xy function return a value on all code paths. This was not really necessary as there is an assert in the path that could have returned without a value. The gcc optimiser seems unable to reason about this in this case causing a warning. --- render/box.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/render/box.c b/render/box.c index 30bafa904..c9bf61df3 100644 --- a/render/box.c +++ b/render/box.c @@ -481,15 +481,18 @@ enum box_walk_dir { static inline struct box *box_move_xy(struct box *b, enum box_walk_dir dir, int *x, int *y) { + struct box *rb = NULL; + switch (dir) { case BOX_WALK_CHILDREN: b = b->children; if (b == NULL) - return NULL; + break; *x += b->x; *y += b->y; if (!box_is_float(b)) { - return b; + rb = b; + break; } /* Fall through */ @@ -503,39 +506,46 @@ static inline struct box *box_move_xy(struct box *b, enum box_walk_dir dir, *x += b->x; *y += b->y; } while (box_is_float(b)); - return b; + rb = b; + break; case BOX_WALK_PARENT: *x -= b->x; *y -= b->y; - return b->parent; + rb = b->parent; + break; case BOX_WALK_FLOAT_CHILDREN: b = b->float_children; if (b == NULL) - return NULL; + break; *x += b->x; *y += b->y; - return b; + rb = b; + break; case BOX_WALK_NEXT_FLOAT_SIBLING: *x -= b->x; *y -= b->y; b = b->next_float; if (b == NULL) - return NULL; + break; *x += b->x; *y += b->y; - return b; + rb = b; + break; case BOX_WALK_FLOAT_CONTAINER: *x -= b->x; *y -= b->y; - return b->float_container; + rb = b->float_container; + break; default: assert(0 && "Bad box walk type."); } + + return rb; } -- cgit v1.2.3