diff options
Diffstat (limited to 'src/locale/localed.c')
-rw-r--r-- | src/locale/localed.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/src/locale/localed.c b/src/locale/localed.c index c949fa3831..21d1ded65c 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -33,18 +33,19 @@ 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; sd_bus_error error = SD_BUS_ERROR_NULL; - unsigned c_set, c_unset, p; + size_t c_set, c_unset; + LocaleVariable p; int r; assert(bus); l_unset = new0(char*, _VARIABLE_LC_MAX); if (!l_unset) - return -ENOMEM; + return log_oom(); l_set = new0(char*, _VARIABLE_LC_MAX); if (!l_set) - return -ENOMEM; + return log_oom(); for (p = 0, c_set = 0, c_unset = 0; p < _VARIABLE_LC_MAX; p++) { const char *name; @@ -57,8 +58,9 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) { else { char *s; - if (asprintf(&s, "%s=%s", name, c->locale[p]) < 0) - return -ENOMEM; + s = strjoin(name, "=", c->locale[p]); + if (!s) + return log_oom(); l_set[c_unset++] = s; } @@ -71,19 +73,19 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) { "org.freedesktop.systemd1.Manager", "UnsetAndSetEnvironment"); if (r < 0) - return r; + return bus_log_create_error(r); r = sd_bus_message_append_strv(m, l_unset); if (r < 0) - return r; + return bus_log_create_error(r); r = sd_bus_message_append_strv(m, l_set); if (r < 0) - return r; + return bus_log_create_error(r); r = sd_bus_call(bus, m, 0, &error, NULL); if (r < 0) - log_error_errno(r, "Failed to update the manager environment, ignoring: %m"); + return log_error_errno(r, "Failed to update the manager environment: %s", bus_error_message(&error, r)); return 0; } @@ -104,7 +106,7 @@ static int vconsole_reload(sd_bus *bus) { "ss", "systemd-vconsole-setup.service", "replace"); if (r < 0) - return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r)); + return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r)); return 0; } @@ -253,20 +255,13 @@ static int property_get_xkb( return -EINVAL; } -static void locale_free(char ***l) { - int p; - - for (p = 0; p < _VARIABLE_LC_MAX; p++) - (*l)[p] = mfree((*l)[p]); -} - static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *error) { - Context *c = userdata; + _cleanup_(locale_variables_freep) char *new_locale[_VARIABLE_LC_MAX] = {}; _cleanup_strv_free_ char **settings = NULL, **l = NULL; - char *new_locale[_VARIABLE_LC_MAX] = {}, **i; - _cleanup_(locale_free) _unused_ char **dummy = new_locale; + Context *c = userdata; bool modified = false; int interactive, p, r; + char **i; assert(m); assert(c); @@ -458,9 +453,7 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro log_info("Changed virtual console keymap to '%s' toggle '%s'", strempty(c->vc_keymap), strempty(c->vc_keymap_toggle)); - r = vconsole_reload(sd_bus_message_get_bus(m)); - if (r < 0) - log_error_errno(r, "Failed to request keymap reload: %m"); + (void) vconsole_reload(sd_bus_message_get_bus(m)); (void) sd_bus_emit_properties_changed( sd_bus_message_get_bus(m), |