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
This commit is contained in:
Paul Cornett
2021-03-24 11:35:38 -07:00
parent 0a28e3267c
commit 024d1543f1

View File

@@ -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<const unsigned*>(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;
}
}
}