summaryrefslogtreecommitdiff
path: root/src/core/main.c
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-09-09 15:45:03 +0200
committerDaniel Mack <github@zonque.org>2015-09-09 15:45:03 +0200
commit01da201420edfb2a57e384f109def05f25429305 (patch)
tree1c3090f3b5200ba62613285553afa0f7a6d30b9a /src/core/main.c
parent37b76fd3ee5a03d76786e7bd1e0f8596e6ce47d6 (diff)
parent74ca738f6a01fb5fc19c5c3899f5cb1fdc1d7f68 (diff)
Merge pull request #1218 from poettering/safe-fclose
util: introduce safe_fclose() and port everything over to it
Diffstat (limited to 'src/core/main.c')
-rw-r--r--src/core/main.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 48b5057a85..be95dc68b2 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -918,8 +918,7 @@ static int parse_argv(int argc, char *argv[]) {
if (!f)
return log_error_errno(errno, "Failed to open serialization fd: %m");
- if (arg_serialization)
- fclose(arg_serialization);
+ safe_fclose(arg_serialization);
arg_serialization = f;
@@ -1059,8 +1058,7 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
fail:
fdset_free(fds);
- if (f)
- fclose(f);
+ safe_fclose(f);
return r;
}
@@ -1679,10 +1677,7 @@ int main(int argc, char *argv[]) {
fdset_free(fds);
fds = NULL;
- if (arg_serialization) {
- fclose(arg_serialization);
- arg_serialization = NULL;
- }
+ arg_serialization = safe_fclose(arg_serialization);
if (queue_default_job) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -1923,10 +1918,7 @@ finish:
* getopt() in argv[], and some cleanups in envp[],
* but let's hope that doesn't matter.) */
- if (arg_serialization) {
- fclose(arg_serialization);
- arg_serialization = NULL;
- }
+ arg_serialization = safe_fclose(arg_serialization);
if (fds) {
fdset_free(fds);
@@ -1966,10 +1958,7 @@ finish:
log_warning_errno(errno, "Failed to execute /sbin/init, giving up: %m");
}
- if (arg_serialization) {
- fclose(arg_serialization);
- arg_serialization = NULL;
- }
+ arg_serialization = safe_fclose(arg_serialization);
if (fds) {
fdset_free(fds);