From d2b6485385566e84d7e13d272aeeb42b5afc3e34 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Wed, 30 Nov 2022 16:18:06 +0100 Subject: [PATCH] localed-util: use _cleanup_ harder --- src/locale/localed-util.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c index 880d0d209c5..8fb65b96997 100644 --- a/src/locale/localed-util.c +++ b/src/locale/localed-util.c @@ -254,7 +254,7 @@ int vconsole_write_data(Context *c) { int x11_write_data(Context *c) { _cleanup_fclose_ FILE *f = NULL; - _cleanup_free_ char *temp_path = NULL; + _cleanup_(unlink_and_freep) char *temp_path = NULL; struct stat st; int r; @@ -300,23 +300,15 @@ int x11_write_data(Context *c) { r = fflush_sync_and_check(f); if (r < 0) - goto fail; + return r; - if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) { - r = -errno; - goto fail; - } + if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) + return -errno; if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) >= 0) c->x11_mtime = timespec_load(&st.st_mtim); return 0; - -fail: - if (temp_path) - (void) unlink(temp_path); - - return r; } static int read_next_mapping(const char* filename, -- 2.47.3