From: Karel Zak Date: Tue, 22 Oct 2024 08:22:08 +0000 (+0200) Subject: hwclock: cleanup save_adjtime() X-Git-Tag: v2.42-start~173 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc325a65d10ed6b136272fe64a67a042b81ae838;p=thirdparty%2Futil-linux.git hwclock: cleanup save_adjtime() Signed-off-by: Karel Zak --- diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index 9e3a957a7..2b33dfbce 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -898,6 +898,7 @@ static int save_adjtime(const struct hwclock_control *ctl, { char *content; /* Stuff to write to disk file */ FILE *fp; + int rc = EXIT_FAILURE; xasprintf(&content, "%f %"PRId64" %f\n%"PRId64"\n%s\n", adjtime->drift_factor, @@ -917,8 +918,7 @@ static int save_adjtime(const struct hwclock_control *ctl, fp = fopen(ctl->adj_file_name, "w"); if (fp == NULL) { warn(_("cannot open %s"), ctl->adj_file_name); - free(content); - return EXIT_FAILURE; + goto done; } rc = fputs(content, fp) < 0; @@ -926,12 +926,14 @@ static int save_adjtime(const struct hwclock_control *ctl, if (rc) { warn(_("cannot update %s"), ctl->adj_file_name); - free(content); - return EXIT_FAILURE; + goto done; } } + + rc = EXIT_SUCCESS; +done: free(content); - return EXIT_SUCCESS; + return rc; } /*