[gnome-control-center] region: fix warning of uninitialized variables



commit b9a684dc1db21a692ed182a32bb6b71c451112b3
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date:   Fri Aug 19 17:13:52 2022 +0200

    region: fix warning of uninitialized variables
    
    ../panels/region/cc-region-panel.c: In function 'set_restart_notification_visible':
    ../panels/region/cc-region-panel.c:131:17: warning: 'current_locale' may be used uninitialized 
[-Wmaybe-uninitialized]
      131 |                 uselocale (current_locale);
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
    ../panels/region/cc-region-panel.c:115:18: note: 'current_locale' was declared here
      115 |         locale_t current_locale;
          |                  ^~~~~~~~~~~~~~
    ../panels/region/cc-region-panel.c:130:34: warning: 'new_locale' may be used uninitialized 
[-Wmaybe-uninitialized]
      130 |         if (locale && new_locale != (locale_t) 0) {
          |                       ~~~~~~~~~~~^~~~~~~~~~~~~~~
    ../panels/region/cc-region-panel.c:114:18: note: 'new_locale' was declared here
      114 |         locale_t new_locale;
          |                  ^~~~~~~~~~

 panels/region/cc-region-panel.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 56e19215e..bba51e930 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -120,19 +120,17 @@ set_restart_notification_visible (CcRegionPanel *self,
 
         if (locale) {
                 new_locale = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
-                if (new_locale == (locale_t) 0)
-                        g_warning ("Failed to create locale %s: %s", locale, g_strerror (errno));
-                else
+                if (new_locale != (locale_t) 0) {
                         current_locale = uselocale (new_locale);
+                        uselocale (current_locale);
+                        freelocale (new_locale);
+                } else {
+                        g_warning ("Failed to create locale %s: %s", locale, g_strerror (errno));
+                }
         }
 
         gtk_info_bar_set_revealed (self->infobar, visible);
 
-        if (locale && new_locale != (locale_t) 0) {
-                uselocale (current_locale);
-                freelocale (new_locale);
-        }
-
         file = get_needs_restart_file ();
 
         if (!visible) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]