From 024d1543f19581780b5dc9c08bfe2e2e8cb43067 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Wed, 24 Mar 2021 11:35:38 -0700 Subject: [PATCH] Fix conditional-uninitialized warning in a different way Rather than dummy initializations, reorganize the code so there is no way the variables can appear to be uninitialized --- src/gtk/settings.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index fb2d4ae79c..3047247737 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -405,23 +405,18 @@ void wxGtkStyleContext::Bg(wxColour& color, int state) const const int i = stride * (cairo_image_surface_get_height(surf) / 2); const unsigned* p = reinterpret_cast(data + i); const unsigned pixel = *p; - guchar r = 0, g = 0, b = 0, a = 0xff; + guchar r, g, b, a = 0xff; switch (cairo_image_surface_get_format(surf)) { case CAIRO_FORMAT_ARGB32: a = guchar(pixel >> 24); + if (a == 0) + break; wxFALLTHROUGH; case CAIRO_FORMAT_RGB24: r = guchar(pixel >> 16); g = guchar(pixel >> 8); b = guchar(pixel); - break; - default: - a = 0; - break; - } - if (a != 0) - { if (a != 0xff) { // un-premultiply @@ -430,6 +425,9 @@ void wxGtkStyleContext::Bg(wxColour& color, int state) const b = guchar((b * 0xff) / a); } color.Set(r, g, b, a); + break; + default: + break; } } }