]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale: inline iterator variable declarations
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 15 Feb 2021 13:17:50 +0000 (14:17 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 15:10:14 +0000 (16:10 +0100)
src/locale/keymap-util.c
src/locale/localectl.c
src/locale/localed.c

index 697133ad84da956a095b43c499c0b2c484daf39a..d0d2d30a346cf5156851429ac6860ce66c225449 100644 (file)
@@ -66,9 +66,7 @@ static void context_free_vconsole(Context *c) {
 }
 
 static void context_free_locale(Context *c) {
-        int p;
-
-        for (p = 0; p < _VARIABLE_LC_MAX; p++)
+        for (LocaleVariable p = 0; p < _VARIABLE_LC_MAX; p++)
                 c->locale[p] = mfree(c->locale[p]);
 }
 
@@ -85,9 +83,7 @@ void context_clear(Context *c) {
 };
 
 void locale_simplify(char *locale[_VARIABLE_LC_MAX]) {
-        int p;
-
-        for (p = VARIABLE_LANG+1; p < _VARIABLE_LC_MAX; p++)
+        for (LocaleVariable p = VARIABLE_LANG+1; p < _VARIABLE_LC_MAX; p++)
                 if (isempty(locale[p]) || streq_ptr(locale[VARIABLE_LANG], locale[p]))
                         locale[p] = mfree(locale[p]);
 }
@@ -138,13 +134,11 @@ int locale_read_data(Context *c, sd_bus_message *m) {
                 if (r < 0)
                         return r;
         } else {
-                int p;
-
                 c->locale_mtime = USEC_INFINITY;
                 context_free_locale(c);
 
                 /* Fill in what we got passed from systemd. */
-                for (p = 0; p < _VARIABLE_LC_MAX; p++) {
+                for (LocaleVariable p = 0; p < _VARIABLE_LC_MAX; p++) {
                         const char *name;
 
                         name = locale_variable_to_string(p);
@@ -294,11 +288,11 @@ int x11_read_data(Context *c, sd_bus_message *m) {
 int locale_write_data(Context *c, char ***settings) {
         _cleanup_strv_free_ char **l = NULL;
         struct stat st;
-        int r, p;
+        int r;
 
         /* Set values will be returned as strv in *settings on success. */
 
-        for (p = 0; p < _VARIABLE_LC_MAX; p++) {
+        for (LocaleVariable p = 0; p < _VARIABLE_LC_MAX; p++) {
                 _cleanup_free_ char *t = NULL;
                 char **u;
                 const char *name;
index c267db9edd9a6c7bbf5f57be23f0483f1820615a..548ac8eb2c357ce330516b4f5de1fac30d2b86c3 100644 (file)
@@ -55,7 +55,6 @@ static void status_info_clear(StatusInfo *info) {
 static void print_overridden_variables(void) {
         _cleanup_(locale_variables_freep) char *variables[_VARIABLE_LC_MAX] = {};
         bool print_warning = true;
-        LocaleVariable j;
         int r;
 
         if (arg_transport != BUS_TRANSPORT_LOCAL)
@@ -82,7 +81,7 @@ static void print_overridden_variables(void) {
                 return;
         }
 
-        for (j = 0; j < _VARIABLE_LC_MAX; j++)
+        for (LocaleVariable j = 0; j < _VARIABLE_LC_MAX; j++)
                 if (variables[j]) {
                         if (print_warning) {
                                 log_warning("Warning: Settings on kernel command line override system locale settings in /etc/locale.conf.\n"
index 97d6592cb81401421a28043d2eeea52d0857770b..9c97313edcad6457fd3f44a5655a6eb8726e2fda 100644 (file)
@@ -37,8 +37,7 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) {
         _cleanup_strv_free_ char **l_set = NULL;
         _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
-        size_t c_set, c_unset;
-        LocaleVariable p;
+        size_t c_set = 0, c_unset = 0;
         int r;
 
         assert(bus);
@@ -51,7 +50,7 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) {
         if (!l_set)
                 return log_oom();
 
-        for (p = 0, c_set = 0, c_unset = 0; p < _VARIABLE_LC_MAX; p++) {
+        for (LocaleVariable p = 0; p < _VARIABLE_LC_MAX; p++) {
                 const char *name;
 
                 name = locale_variable_to_string(p);
@@ -178,7 +177,7 @@ static int property_get_locale(
 
         Context *c = userdata;
         _cleanup_strv_free_ char **l = NULL;
-        int p, q, r;
+        int r;
 
         r = locale_read_data(c, reply);
         if (r < 0)
@@ -188,7 +187,7 @@ static int property_get_locale(
         if (!l)
                 return -ENOMEM;
 
-        for (p = 0, q = 0; p < _VARIABLE_LC_MAX; p++) {
+        for (LocaleVariable p = 0, q = 0; p < _VARIABLE_LC_MAX; p++) {
                 char *t;
                 const char *name;