diff options
author | Daniel Mack <github@zonque.org> | 2015-07-29 20:43:54 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-07-29 20:43:54 +0200 |
commit | 65c85ef5118d88bc0d3459b6e8854bf1846190b9 (patch) | |
tree | 3c60aceafd3cbf6fe12eb6db934350950f4425cd /src/locale/localed.c | |
parent | 1051d049a8a5811135d83a89a430c5be846866ca (diff) | |
parent | dacd6cee76a08331b8c8616c5f30f70ee49aa2f9 (diff) |
Merge pull request #779 from poettering/fflush-and-check
tree-wide: port everything over to fflush_and_check()
Diffstat (limited to 'src/locale/localed.c')
-rw-r--r-- | src/locale/localed.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/locale/localed.c b/src/locale/localed.c index 88756542fd..e8a8f17d86 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -476,15 +476,25 @@ static int x11_write_data(Context *c) { fprintf(f, " Option \"XkbOptions\" \"%s\"\n", c->x11_options); fputs("EndSection\n", f); - fflush(f); - if (ferror(f) || rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) { + r = fflush_and_check(f); + if (r < 0) + goto fail; + + if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) { r = -errno; - unlink("/etc/X11/xorg.conf.d/00-keyboard.conf"); - unlink(temp_path); - return r; - } else - return 0; + goto fail; + } + + return 0; + +fail: + (void) unlink("/etc/X11/xorg.conf.d/00-keyboard.conf"); + + if (temp_path) + (void) unlink(temp_path); + + return r; } static int vconsole_reload(sd_bus *bus) { |