backends/native: Avoid -Wmaybe-uninitialized warning

Ensure that color_ptr gets set, and avoid color_char usage too in
that case. Fixes:

  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c: In function ‘meta_monitor_manager_kms_set_crtc_gamma’:
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:370:7: warning: ‘color_char’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    370 |       g_string_append_printf (string, " %c: ", color_char);
        |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:351:12: note: ‘color_char’ was declared here
    351 |       char color_char;
        |            ^~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:391:36: warning: ‘color_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    391 |                                   (*color_ptr)[i]);
        |                                   ~^~~~~~~~~~~
  ../../../../Source/gnome/mutter/src/backends/native/meta-monitor-manager-kms.c:350:24: note: ‘color_ptr’ was declared here
    350 |       unsigned short **color_ptr;
        |                        ^~~~~~~~~

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1624>
This commit is contained in:
Carlos Garnacho 2020-12-04 16:17:16 +01:00 committed by Marge Bot
parent 745ccc5b01
commit 20ac791f4b

View File

@ -347,7 +347,7 @@ generate_gamma_ramp_string (size_t size,
string = g_string_new ("["); string = g_string_new ("[");
for (color = 0; color < 3; color++) for (color = 0; color < 3; color++)
{ {
unsigned short **color_ptr; unsigned short **color_ptr = NULL;
char color_char; char color_char;
size_t i; size_t i;
@ -367,6 +367,7 @@ generate_gamma_ramp_string (size_t size,
break; break;
} }
g_assert (color_ptr);
g_string_append_printf (string, " %c: ", color_char); g_string_append_printf (string, " %c: ", color_char);
for (i = 0; i < MIN (4, size); i++) for (i = 0; i < MIN (4, size); i++)
{ {