#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "glob-util.h"
#include "journal-upload.h"
#include "log.h"
}
static int update_cursor_state(Uploader *u) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
- if (temp_path)
- (void) unlink(temp_path);
-
(void) unlink(u->state_file);
return log_error_errno(r, "Failed to save state %s: %m", u->state_file);
const char *id;
char *path;
_cleanup_fclose_ FILE *f = NULL;
- _cleanup_free_ char *path_tmp = NULL;
+ _cleanup_(unlink_and_freep) char *path_tmp = NULL;
bool has_info;
int r;
goto fail;
}
+ path_tmp = mfree(path_tmp);
+
log_device_debug(device, "sd-device: Created %s file '%s' for '%s'", has_info ? "db" : "empty",
path, device->devpath);
fail:
(void) unlink(path);
- (void) unlink(path_tmp);
return log_device_debug_errno(device, r, "sd-device: Failed to create %s file '%s' for '%s'", has_info ? "db" : "empty", path, device->devpath);
}
}
static int update_schedule_file(Manager *m) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
- (void) unlink(temp_path);
(void) unlink(SHUTDOWN_SCHEDULE_FILE);
return log_error_errno(r, "Failed to write information about scheduled shutdowns: %m");
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "io-util.h"
#include "logind-dbus.h"
#include "logind-inhibit.h"
}
static int inhibitor_save(Inhibitor *i) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(i->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save inhibit data %s: %m", i->state_file);
}
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "logind-seat-dbus.h"
#include "logind-seat.h"
#include "logind-session-dbus.h"
}
int seat_save(Seat *s) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(s->state_file);
-
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save seat data %s: %m", s->state_file);
}
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "io-util.h"
#include "logind-dbus.h"
#include "logind-seat-dbus.h"
}
int session_save(Session *s) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(s->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save session data %s: %m", s->state_file);
}
}
static int user_save_internal(User *u) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(u->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save user data %s: %m", u->state_file);
}
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "hashmap.h"
#include "machine-dbus.h"
#include "machine.h"
}
int machine_save(Machine *m) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
+
if (m->unit) {
char *sl;
fail:
(void) unlink(m->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save machine data %s: %m", m->state_file);
}
#include "env-file.h"
#include "fd-util.h"
#include "fileio.h"
+#include "fs-util.h"
#include "log-link.h"
#include "mkdir.h"
#include "netif-util.h"
}
int link_save_user(Link *l) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *v;
int r;
goto fail;
}
+ temp_path = mfree(temp_path);
+
return 0;
fail:
(void) unlink(l->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_link_error_errno(l, r, "Failed to save link data %s: %m", l->state_file);
}