From 0e517d0fe102296e4b44253c1673cb767b5f444c Mon Sep 17 00:00:00 2001 From: rbuj Date: Tue, 1 Feb 2022 11:07:36 +0100 Subject: boxes: fix build warning -Wstring-conversion --- src/core/boxes.c | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/core/boxes.c b/src/core/boxes.c index a9006ede..9ef8d94d 100644 --- a/src/core/boxes.c +++ b/src/core/boxes.c @@ -1334,9 +1334,10 @@ get_disjoint_strut_rect_list_in_region (const GSList *old_struts, gint meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b) { - const MetaEdge *a_edge_rect = (gconstpointer) a; - const MetaEdge *b_edge_rect = (gconstpointer) b; - int a_compare, b_compare; + const MetaEdge *a_edge_rect = a; + const MetaEdge *b_edge_rect = b; + int a_compare = 0; + int b_compare = 0; /* Edges must be both vertical or both horizontal, or it doesn't make * sense to compare them. @@ -1344,33 +1345,31 @@ meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b) g_assert ((a_edge_rect->rect.width == 0 && b_edge_rect->rect.width == 0) || (a_edge_rect->rect.height == 0 && b_edge_rect->rect.height == 0)); - a_compare = b_compare = 0; /* gcc-3.4.2 sucks at figuring initialized'ness */ - - if (a_edge_rect->side_type == META_SIDE_LEFT || - a_edge_rect->side_type == META_SIDE_RIGHT) - { - a_compare = a_edge_rect->rect.x; - b_compare = b_edge_rect->rect.x; - if (a_compare == b_compare) - { - a_compare = a_edge_rect->rect.y; - b_compare = b_edge_rect->rect.y; - } - } - else if (a_edge_rect->side_type == META_SIDE_TOP || - a_edge_rect->side_type == META_SIDE_BOTTOM) + switch (a_edge_rect->side_type) { - a_compare = a_edge_rect->rect.y; - b_compare = b_edge_rect->rect.y; - if (a_compare == b_compare) - { - a_compare = a_edge_rect->rect.x; - b_compare = b_edge_rect->rect.x; - } + case META_SIDE_LEFT: + case META_SIDE_RIGHT: + a_compare = a_edge_rect->rect.x; + b_compare = b_edge_rect->rect.x; + if (a_compare == b_compare) + { + a_compare = a_edge_rect->rect.y; + b_compare = b_edge_rect->rect.y; + } + break; + case META_SIDE_TOP: + case META_SIDE_BOTTOM: + a_compare = a_edge_rect->rect.y; + b_compare = b_edge_rect->rect.y; + if (a_compare == b_compare) + { + a_compare = a_edge_rect->rect.x; + b_compare = b_edge_rect->rect.x; + } + break; + default: + g_assert_not_reached (); } - else - g_assert ("Some idiot wanted to sort sides of different types.\n"); - return a_compare - b_compare; /* positive value denotes a > b ... */ } -- cgit v1.2.1