diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-15 14:17:50 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-16 16:10:14 +0100 |
commit | ab4ab13c748b86b19ead4ab3bd39a3e4f5d6deb3 (patch) | |
tree | eba5573e2d66b6a14c5f3768f75049aef4184e54 /src/locale | |
parent | b70935ac65be05087a1a694ee19488cb7fce926d (diff) | |
download | systemd-ab4ab13c748b86b19ead4ab3bd39a3e4f5d6deb3.tar.gz |
locale: inline iterator variable declarations
Diffstat (limited to 'src/locale')
-rw-r--r-- | src/locale/keymap-util.c | 16 | ||||
-rw-r--r-- | src/locale/localectl.c | 3 | ||||
-rw-r--r-- | src/locale/localed.c | 9 |
3 files changed, 10 insertions, 18 deletions
diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c index 697133ad84..d0d2d30a34 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 c267db9edd..548ac8eb2c 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 97d6592cb8..9c97313edc 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; |