From 7c290c6bb60c65b3b0a336d0595490f9e0f7b3f2 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Wed, 10 Apr 2019 21:46:24 +0200 Subject: caja-icon-canvas-item: avoid 'cppcheck' warning Fixes 'cppcheck' warning: [libcaja-private/caja-icon-canvas-item.c:850]: (error) Uninitialized variable: real_text_height --- libcaja-private/caja-icon-canvas-item.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'libcaja-private/caja-icon-canvas-item.c') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 155fa788..1a35fda7 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -830,21 +830,20 @@ compute_text_rectangle (const CajaIconCanvasItem *item, text_rectangle.y0 = icon_rectangle.y1; text_rectangle.x1 = text_rectangle.x0 + text_width; - if (usage == BOUNDS_USAGE_FOR_LAYOUT) + switch (usage) { - real_text_height = text_height_for_layout; - } - else if (usage == BOUNDS_USAGE_FOR_ENTIRE_ITEM) - { - real_text_height = text_height_for_entire_text; - } - else if (usage == BOUNDS_USAGE_FOR_DISPLAY) - { - real_text_height = text_height; - } - else - { - g_assert_not_reached (); + case BOUNDS_USAGE_FOR_LAYOUT: + real_text_height = text_height_for_layout; + break; + case BOUNDS_USAGE_FOR_ENTIRE_ITEM: + real_text_height = text_height_for_entire_text; + break; + case BOUNDS_USAGE_FOR_DISPLAY: + real_text_height = text_height; + break; + default: + g_assert_not_reached (); + break; } text_rectangle.y1 = text_rectangle.y0 + real_text_height + LABEL_OFFSET / pixels_per_unit; -- cgit v1.2.1