From: Zbigniew Jędrzejewski-Szmek Date: Mon, 15 Feb 2021 13:17:50 +0000 (+0100) Subject: locale: inline iterator variable declarations X-Git-Tag: v248-rc1~92^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab4ab13c748b86b19ead4ab3bd39a3e4f5d6deb3;p=thirdparty%2Fsystemd.git locale: inline iterator variable declarations --- diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c index 697133ad84d..d0d2d30a346 100644 --- a/src/locale/keymap-util.c +++ b/src/locale/keymap-util.c @@ -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; diff --git a/src/locale/localectl.c b/src/locale/localectl.c index c267db9edd9..548ac8eb2c3 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -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" diff --git a/src/locale/localed.c b/src/locale/localed.c index 97d6592cb81..9c97313edca 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -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;