diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-12-20 14:54:03 +0100 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2023-01-23 12:29:11 +0100 |
commit | c2ddaed483a190b09a94b3b87a6f313bbe8a85a9 (patch) | |
tree | f0ff13a344999b85d8587ff8f4f9969456c4bf16 /src/locale/localed-util.c | |
parent | locale: do not use alloca() for strings which can be potentially arbitrary (diff) | |
download | systemd-c2ddaed483a190b09a94b3b87a6f313bbe8a85a9.tar.xz systemd-c2ddaed483a190b09a94b3b87a6f313bbe8a85a9.zip |
locale: rename context_free_vconsole() -> context_clear_vconsole()
Similary, this also renames context_free_x11() -> context_clear_x11(),
to make it clear that these functions do not free Context.
Also, this makes context_clear() support to be called more than once.
Diffstat (limited to 'src/locale/localed-util.c')
-rw-r--r-- | src/locale/localed-util.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c index 03ea98d521..140a7fc03e 100644 --- a/src/locale/localed-util.c +++ b/src/locale/localed-util.c @@ -56,7 +56,7 @@ static const char* systemd_language_fallback_map(void) { return SYSTEMD_LANGUAGE_FALLBACK_MAP; } -static void context_free_x11(Context *c) { +static void context_clear_x11(Context *c) { assert(c); c->x11_layout = mfree(c->x11_layout); @@ -65,7 +65,7 @@ static void context_free_x11(Context *c) { c->x11_variant = mfree(c->x11_variant); } -static void context_free_vconsole(Context *c) { +static void context_clear_vconsole(Context *c) { assert(c); c->vc_keymap = mfree(c->vc_keymap); @@ -76,14 +76,14 @@ void context_clear(Context *c) { assert(c); locale_context_clear(&c->locale_context); - context_free_x11(c); - context_free_vconsole(c); + context_clear_x11(c); + context_clear_vconsole(c); - sd_bus_message_unref(c->locale_cache); - sd_bus_message_unref(c->x11_cache); - sd_bus_message_unref(c->vc_cache); + c->locale_cache = sd_bus_message_unref(c->locale_cache); + c->x11_cache = sd_bus_message_unref(c->x11_cache); + c->vc_cache = sd_bus_message_unref(c->vc_cache); - bus_verify_polkit_async_registry_free(c->polkit_registry); + c->polkit_registry = bus_verify_polkit_async_registry_free(c->polkit_registry); }; int locale_read_data(Context *c, sd_bus_message *m) { @@ -119,7 +119,7 @@ int vconsole_read_data(Context *c, sd_bus_message *m) { fd = RET_NERRNO(open("/etc/vconsole.conf", O_CLOEXEC | O_PATH)); if (fd == -ENOENT) { c->vc_stat = (struct stat) {}; - context_free_vconsole(c); + context_clear_vconsole(c); return 0; } if (fd < 0) @@ -133,7 +133,7 @@ int vconsole_read_data(Context *c, sd_bus_message *m) { return 0; c->vc_stat = st; - context_free_vconsole(c); + context_clear_vconsole(c); return parse_env_file_fd(fd, "/etc/vconsole.conf", "KEYMAP", &c->vc_keymap, @@ -161,7 +161,7 @@ int x11_read_data(Context *c, sd_bus_message *m) { fd = RET_NERRNO(open("/etc/X11/xorg.conf.d/00-keyboard.conf", O_CLOEXEC | O_PATH)); if (fd == -ENOENT) { c->x11_stat = (struct stat) {}; - context_free_x11(c); + context_clear_x11(c); return 0; } if (fd < 0) @@ -175,7 +175,7 @@ int x11_read_data(Context *c, sd_bus_message *m) { return 0; c->x11_stat = st; - context_free_x11(c); + context_clear_x11(c); fd_ro = fd_reopen(fd, O_CLOEXEC | O_RDONLY); if (fd_ro < 0) @@ -399,7 +399,7 @@ int vconsole_convert_to_x11(Context *c) { !isempty(c->x11_variant) || !isempty(c->x11_options); - context_free_x11(c); + context_clear_x11(c); } else { _cleanup_fclose_ FILE *f = NULL; const char *map; @@ -631,7 +631,7 @@ int x11_convert_to_vconsole(Context *c) { !isempty(c->vc_keymap) || !isempty(c->vc_keymap_toggle); - context_free_vconsole(c); + context_clear_vconsole(c); } else { _cleanup_free_ char *new_keymap = NULL; int r; @@ -648,8 +648,8 @@ int x11_convert_to_vconsole(Context *c) { log_notice("No conversion to virtual console map found for \"%s\".", c->x11_layout); if (!streq_ptr(c->vc_keymap, new_keymap)) { - free_and_replace(c->vc_keymap, new_keymap); - c->vc_keymap_toggle = mfree(c->vc_keymap_toggle); + context_clear_vconsole(c); + c->vc_keymap = TAKE_PTR(new_keymap); modified = true; } } |