summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-04-12 23:10:21 +0100
committerLuca Boccassi <luca.boccassi@microsoft.com>2021-04-14 12:25:06 +0100
commitc2b2df604b845b4e1697d0911935e6644323c5a6 (patch)
tree010d290588b55b7ed97f9e3066f56f9a9d08d77d /src
parentbe084c0dd1f1a06320e507c0e6a9de23b37556e1 (diff)
downloadsystemd-c2b2df604b845b4e1697d0911935e6644323c5a6.tar.gz
tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
Diffstat (limited to 'src')
-rw-r--r--src/activate/activate.c6
-rw-r--r--src/basic/efivars.c2
-rw-r--r--src/basic/path-lookup.c2
-rw-r--r--src/basic/terminal-util.c4
-rw-r--r--src/basic/time-util.c2
-rw-r--r--src/boot/bless-boot.c2
-rw-r--r--src/boot/bootctl.c2
-rw-r--r--src/boot/efi/boot.c2
-rw-r--r--src/boot/efi/stub.c6
-rw-r--r--src/boot/efi/util.c2
-rw-r--r--src/busctl/busctl.c8
-rw-r--r--src/core/dbus-execute.c4
-rw-r--r--src/core/dbus-path.c2
-rw-r--r--src/core/execute.c4
-rw-r--r--src/core/job.c2
-rw-r--r--src/core/main.c2
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/namespace.c4
-rw-r--r--src/core/service.c2
-rw-r--r--src/core/unit.c6
-rw-r--r--src/coredump/coredump.c2
-rw-r--r--src/coredump/coredumpctl.c4
-rw-r--r--src/cryptsetup/cryptsetup-keyfile.c2
-rw-r--r--src/environment-d-generator/environment-d-generator.c2
-rw-r--r--src/fstab-generator/fstab-generator.c2
-rw-r--r--src/journal-remote/journal-gatewayd.c2
-rw-r--r--src/journal-remote/journal-remote.c2
-rw-r--r--src/journal/journalctl.c8
-rw-r--r--src/journal/journald-stream.c4
-rw-r--r--src/libsystemd-network/fuzz-dhcp6-client.c2
-rw-r--r--src/libsystemd/sd-journal/journal-vacuum.c2
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c2
-rw-r--r--src/libsystemd/sd-login/sd-login.c2
-rw-r--r--src/locale/keymap-util.c2
-rw-r--r--src/locale/localed.c2
-rw-r--r--src/login/logind-core.c2
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/login/logind-session.c8
-rw-r--r--src/machine/machine.c6
-rw-r--r--src/network/netdev/tuntap.c2
-rw-r--r--src/network/wait-online/wait-online.c2
-rw-r--r--src/portable/portable.c2
-rw-r--r--src/portable/portablectl.c2
-rw-r--r--src/resolve/resolved-dns-scope.c2
-rw-r--r--src/shared/acl-util.c6
-rw-r--r--src/shared/bus-wait-for-jobs.c2
-rw-r--r--src/shared/clean-ipc.c2
-rw-r--r--src/shared/clock-util.c2
-rw-r--r--src/shared/format-table.c30
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/logs-show.c4
-rw-r--r--src/shared/net-condition.c2
-rw-r--r--src/shared/sleep-config.c2
-rw-r--r--src/systemctl/systemctl-edit.c2
-rw-r--r--src/systemctl/systemctl-list-units.c2
-rw-r--r--src/systemctl/systemctl-show.c4
-rw-r--r--src/sysv-generator/sysv-generator.c6
-rw-r--r--src/timesync/wait-sync.c2
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c2
-rw-r--r--src/udev/scsi_id/scsi_id.c2
-rw-r--r--src/vconsole/vconsole-setup.c4
61 files changed, 106 insertions, 106 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c
index f298b1d491..8c61c3ca7f 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -151,7 +151,7 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd,
envp[n_env++] = k;
} else {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
const char *n;
p = strjoin(*s, "=");
@@ -421,7 +421,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_FDNAME: {
- _cleanup_strv_free_ char **names;
+ _cleanup_strv_free_ char **names = NULL;
char **s;
names = strv_split(optarg, ":");
@@ -430,7 +430,7 @@ static int parse_argv(int argc, char *argv[]) {
STRV_FOREACH(s, names)
if (!fdname_is_valid(*s)) {
- _cleanup_free_ char *esc;
+ _cleanup_free_ char *esc = NULL;
esc = cescape(*s);
log_warning("File descriptor name \"%s\" is not valid.", esc);
diff --git a/src/basic/efivars.c b/src/basic/efivars.c
index 2139cf3a69..7e1e9e6047 100644
--- a/src/basic/efivars.c
+++ b/src/basic/efivars.c
@@ -350,7 +350,7 @@ int cache_efi_options_variable(void) {
* (NB: For testing purposes, we still check the $SYSTEMD_EFI_OPTIONS env var before accessing this
* cache, even when in SecureBoot mode.) */
if (is_efi_secure_boot()) {
- _cleanup_free_ char *k;
+ _cleanup_free_ char *k = NULL;
k = efi_variable_path(EFI_VENDOR_SYSTEMD, "SystemdOptions");
if (!k)
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c
index 96b82170d0..e53c2302b1 100644
--- a/src/basic/path-lookup.c
+++ b/src/basic/path-lookup.c
@@ -772,7 +772,7 @@ void lookup_paths_log(LookupPaths *p) {
log_debug("Ignoring unit files.");
p->search_path = strv_free(p->search_path);
} else {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = strv_join(p->search_path, "\n\t");
log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t));
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 1a3f9ccb33..fafdaaa090 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -52,7 +52,7 @@ static volatile int cached_color_mode = _COLOR_INVALID;
static volatile int cached_underline_enabled = -1;
int chvt(int vt) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
/* Switch to the specified vt number. If the VT is specified <= 0 switch to the VT the kernel log messages go,
* if that's configured. */
@@ -514,7 +514,7 @@ int terminal_vhangup_fd(int fd) {
}
int terminal_vhangup(const char *name) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
fd = open_terminal(name, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 3c2b25bd2a..78d0390a00 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -1547,7 +1547,7 @@ int time_change_fd(void) {
.it_value.tv_sec = TIME_T_MAX,
};
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
assert_cc(sizeof(time_t) == sizeof(TIME_T_MAX));
diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c
index bd6f64915d..97ad1e0cb5 100644
--- a/src/boot/bless-boot.c
+++ b/src/boot/bless-boot.c
@@ -126,7 +126,7 @@ static int acquire_path(void) {
strv_free_and_replace(arg_path, a);
if (DEBUG_LOGGING) {
- _cleanup_free_ char *j;
+ _cleanup_free_ char *j = NULL;
j = strv_join(arg_path, ":");
log_debug("Using %s as boot loader drop-in search path.", j);
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 04cc7664e5..a684717bb0 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -312,7 +312,7 @@ static int status_variables(void) {
}
static int boot_entry_file_check(const char *root, const char *p) {
- _cleanup_free_ char *path;
+ _cleanup_free_ char *path = NULL;
path = path_join(root, p);
if (!path)
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index 35248db009..24efe5de1d 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -456,7 +456,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
device_path = DevicePathFromHandle(entry->device);
if (device_path) {
- _cleanup_freepool_ CHAR16 *str;
+ _cleanup_freepool_ CHAR16 *str = NULL;
str = DevicePathToStr(device_path);
Print(L"device handle '%s'\n", str);
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index 1d9a5f07ab..082fe91c9e 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -92,7 +92,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
* is non-NULL explicitly.) */
if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS &&
loaded_image->FilePath) {
- _cleanup_freepool_ CHAR16 *s;
+ _cleanup_freepool_ CHAR16 *s = NULL;
s = DevicePathToStr(loaded_image->FilePath);
efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
@@ -100,7 +100,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) {
- _cleanup_freepool_ CHAR16 *s;
+ _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
@@ -108,7 +108,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* ditto for LoaderFirmwareType */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) {
- _cleanup_freepool_ CHAR16 *s;
+ _cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index 06fbd500e5..0061e03eba 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -379,7 +379,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
return err;
if (size == 0) {
- _cleanup_freepool_ EFI_FILE_INFO *info;
+ _cleanup_freepool_ EFI_FILE_INFO *info = NULL;
info = LibFileInfo(handle);
if (!info)
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index cbc24bc251..f081e98ae0 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -797,7 +797,7 @@ static Set* member_set_free(Set *s) {
DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free);
static int on_interface(const char *interface, uint64_t flags, void *userdata) {
- _cleanup_(member_freep) Member *m;
+ _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata;
int r;
@@ -828,7 +828,7 @@ static int on_interface(const char *interface, uint64_t flags, void *userdata) {
}
static int on_method(const char *interface, const char *name, const char *signature, const char *result, uint64_t flags, void *userdata) {
- _cleanup_(member_freep) Member *m;
+ _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata;
int r;
@@ -871,7 +871,7 @@ static int on_method(const char *interface, const char *name, const char *signat
}
static int on_signal(const char *interface, const char *name, const char *signature, uint64_t flags, void *userdata) {
- _cleanup_(member_freep) Member *m;
+ _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata;
int r;
@@ -910,7 +910,7 @@ static int on_signal(const char *interface, const char *name, const char *signat
}
static int on_property(const char *interface, const char *name, const char *signature, bool writable, uint64_t flags, void *userdata) {
- _cleanup_(member_freep) Member *m;
+ _cleanup_(member_freep) Member *m = NULL;
Set *members = userdata;
int r;
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 3d4a06c0ff..3012c87864 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -1627,7 +1627,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHash=");
} else {
- _cleanup_free_ void *p;
+ _cleanup_free_ void *p = NULL;
encoded = hexmem(roothash_decoded, roothash_decoded_size);
if (!encoded)
@@ -1673,7 +1673,7 @@ int bus_exec_context_set_transient_property(
unit_write_settingf(u, flags, name, "RootHashSignature=");
} else {
- _cleanup_free_ void *p;
+ _cleanup_free_ void *p = NULL;
ssize_t len;
len = base64mem(roothash_sig_decoded, roothash_sig_decoded_size, &encoded);
diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c
index 14e77d783d..e132cd2b3c 100644
--- a/src/core/dbus-path.c
+++ b/src/core/dbus-path.c
@@ -96,7 +96,7 @@ static int bus_path_set_transient_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path in %s is not absolute: %s", type_name, path);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
- _cleanup_free_ char *k;
+ _cleanup_free_ char *k = NULL;
PathSpec *s;
k = strdup(path);
diff --git a/src/core/execute.c b/src/core/execute.c
index 4d6b75e845..9f54ad424b 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -4639,7 +4639,7 @@ static int exec_child(
final_argv = command->argv;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *line;
+ _cleanup_free_ char *line = NULL;
line = exec_command_line(final_argv);
if (line)
@@ -4933,7 +4933,7 @@ int exec_context_destroy_runtime_directory(const ExecContext *c, const char *run
return 0;
STRV_FOREACH(i, c->directories[EXEC_DIRECTORY_RUNTIME].paths) {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
if (exec_directory_is_private(c, EXEC_DIRECTORY_RUNTIME))
p = path_join(runtime_prefix, "private", *i);
diff --git a/src/core/job.c b/src/core/job.c
index 56c99f93eb..d313ebdb8e 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -844,7 +844,7 @@ static void job_print_done_status_message(Unit *u, JobType t, JobResult result)
REENABLE_WARNING;
if (t == JOB_START && result == JOB_FAILED) {
- _cleanup_free_ char *quoted;
+ _cleanup_free_ char *quoted = NULL;
quoted = shell_maybe_quote(u->id, ESCAPE_BACKSLASH);
manager_status_printf(u->manager, STATUS_TYPE_NORMAL, NULL, "See 'systemctl status %s' for details.", strna(quoted));
diff --git a/src/core/main.c b/src/core/main.c
index 63254b4a9c..54ef7d182a 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -2036,7 +2036,7 @@ static void log_execution_mode(bool *ret_first_boot) {
}
} else {
if (DEBUG_LOGGING) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = uid_to_name(getuid());
log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (%s)",
diff --git a/src/core/manager.c b/src/core/manager.c
index f7f67065c6..b41b640464 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -248,7 +248,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
}
static int have_ask_password(void) {
- _cleanup_closedir_ DIR *dir;
+ _cleanup_closedir_ DIR *dir = NULL;
struct dirent *de;
dir = opendir("/run/systemd/ask-password");
diff --git a/src/core/namespace.c b/src/core/namespace.c
index ccea336fee..7eb42ee405 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -2092,7 +2092,7 @@ int setup_namespace(
}
if (log_namespace) {
- _cleanup_free_ char *q;
+ _cleanup_free_ char *q = NULL;
q = strjoin("/run/systemd/journal.", log_namespace);
if (!q) {
@@ -2331,7 +2331,7 @@ int mount_image_add(MountImage **m, size_t *n, const MountImage *item) {
}
LIST_FOREACH(mount_options, i, item->mount_options) {
- _cleanup_(mount_options_free_allp) MountOptions *o;
+ _cleanup_(mount_options_free_allp) MountOptions *o = NULL;
o = new(MountOptions, 1);
if (!o)
diff --git a/src/core/service.c b/src/core/service.c
index 550db40631..fb97bbeaae 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -4269,7 +4269,7 @@ int service_set_socket_fd(Service *s, int fd, Socket *sock, bool selinux_context
if (getpeername_pretty(fd, true, &peer) >= 0) {
if (UNIT(s)->description) {
- _cleanup_free_ char *a;
+ _cleanup_free_ char *a = NULL;
a = strjoin(UNIT(s)->description, " (", peer, ")");
if (!a)
diff --git a/src/core/unit.c b/src/core/unit.c
index cf83272dcb..864bcd3d6e 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -557,7 +557,7 @@ static void unit_free_requires_mounts_for(Unit *u) {
assert(u);
for (;;) {
- _cleanup_free_ char *path;
+ _cleanup_free_ char *path = NULL;
path = hashmap_steal_first_key(u->requires_mounts_for);
if (!path)
@@ -1063,7 +1063,7 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
char **dp;
STRV_FOREACH(dp, c->directories[dt].paths) {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = path_join(u->manager->prefix[dt], *dp);
if (!p)
@@ -2184,7 +2184,7 @@ static int unit_log_resources(Unit *u) {
if (n_message_parts == 0)
t = strjoina("MESSAGE=", u->id, ": Completed.");
else {
- _cleanup_free_ char *joined;
+ _cleanup_free_ char *joined = NULL;
message_parts[n_message_parts] = NULL;
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index b6cc7e3887..62467d4cf9 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -588,7 +588,7 @@ static int compose_open_fds(pid_t pid, char **open_fds) {
static int get_process_ns(pid_t pid, const char *namespace, ino_t *ns) {
const char *p;
struct stat stbuf;
- _cleanup_close_ int proc_ns_dir_fd;
+ _cleanup_close_ int proc_ns_dir_fd = -1;
p = procfs_file_alloca(pid, "ns");
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 02bad966c1..9a577d47c8 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -139,7 +139,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
return r;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *filter;
+ _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j);
log_debug("Journal filter: %s", filter);
@@ -979,7 +979,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
if (filename) {
#if HAVE_COMPRESSION
- _cleanup_close_ int fdf;
+ _cleanup_close_ int fdf = -1;
fdf = open(filename, O_RDONLY | O_CLOEXEC);
if (fdf < 0) {
diff --git a/src/cryptsetup/cryptsetup-keyfile.c b/src/cryptsetup/cryptsetup-keyfile.c
index a6281fbdee..55c1442ed6 100644
--- a/src/cryptsetup/cryptsetup-keyfile.c
+++ b/src/cryptsetup/cryptsetup-keyfile.c
@@ -33,7 +33,7 @@ int find_key_file(
}
STRV_FOREACH(i, search_path) {
- _cleanup_free_ char *joined;
+ _cleanup_free_ char *joined = NULL;
joined = path_join(*i, key_file);
if (!joined)
diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c
index 1c51cf6b2c..852e29f11d 100644
--- a/src/environment-d-generator/environment-d-generator.c
+++ b/src/environment-d-generator/environment-d-generator.c
@@ -29,7 +29,7 @@ static int environment_dirs(char ***ret) {
return r;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = strv_join(dirs, "\n\t");
log_debug("Looking for environment.d files in (higher priority first):\n\t%s", strna(t));
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 8c1087a9a3..69ba4bfc64 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -460,7 +460,7 @@ static int add_mount(
return r;
if (!isempty(fstype) && !streq(fstype, "auto")) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = specifier_escape(fstype);
if (!t)
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index 4cefe3918c..a2f166a881 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -311,7 +311,7 @@ static int request_parse_range(
colon2 = strchr(colon + 1, ':');
if (colon2) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = strndup(colon + 1, colon2 - colon - 1);
if (!t)
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 6f71248aaf..9600e5f732 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -40,7 +40,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
break;
case JOURNAL_WRITE_SPLIT_HOST: {
- _cleanup_free_ char *name;
+ _cleanup_free_ char *name = NULL;
assert(host);
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 4b3e697855..b4a8bd1bfb 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1158,7 +1158,7 @@ static int add_matches(sd_journal *j, char **args) {
if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
if (executable_is_script(p, &interpreter) > 0) {
- _cleanup_free_ char *comm;
+ _cleanup_free_ char *comm = NULL;
comm = strndup(basename(p), 15);
if (!comm)
@@ -1537,7 +1537,7 @@ static int get_possible_units(
char **patterns,
Set **units) {
- _cleanup_set_free_free_ Set *found;
+ _cleanup_set_free_free_ Set *found = NULL;
const char *field;
int r;
@@ -2182,7 +2182,7 @@ int main(int argc, char *argv[]) {
case ACTION_LIST_CATALOG:
case ACTION_DUMP_CATALOG:
case ACTION_UPDATE_CATALOG: {
- _cleanup_free_ char *database;
+ _cleanup_free_ char *database = NULL;
database = path_join(arg_root, CATALOG_DATABASE);
if (!database) {
@@ -2436,7 +2436,7 @@ int main(int argc, char *argv[]) {
goto finish;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *filter;
+ _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j);
if (!filter)
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 7bc26097f3..385dc4b58f 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -189,7 +189,7 @@ static int stdout_stream_save(StdoutStream *s) {
s->id_field + STRLEN("_STREAM_ID="));
if (!isempty(s->identifier)) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->identifier);
if (!escaped) {
@@ -201,7 +201,7 @@ static int stdout_stream_save(StdoutStream *s) {
}
if (!isempty(s->unit_id)) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->unit_id);
if (!escaped) {
diff --git a/src/libsystemd-network/fuzz-dhcp6-client.c b/src/libsystemd-network/fuzz-dhcp6-client.c
index acb8d9b98c..7ebe01286d 100644
--- a/src/libsystemd-network/fuzz-dhcp6-client.c
+++ b/src/libsystemd-network/fuzz-dhcp6-client.c
@@ -23,7 +23,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
}
static void fuzz_client(const uint8_t *data, size_t size, bool is_information_request_enabled) {
- _cleanup_(sd_event_unrefp) sd_event *e;
+ _cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
struct in6_addr address = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } } };
diff --git a/src/libsystemd/sd-journal/journal-vacuum.c b/src/libsystemd/sd-journal/journal-vacuum.c
index c173664146..0f1c9eb8f7 100644
--- a/src/libsystemd/sd-journal/journal-vacuum.c
+++ b/src/libsystemd/sd-journal/journal-vacuum.c
@@ -88,7 +88,7 @@ static void patch_realtime(
}
static int journal_file_empty(int dir_fd, const char *name) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
struct stat st;
le64_t n_entries;
ssize_t n;
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index be92f803c9..c90b4c926e 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -1860,7 +1860,7 @@ static int add_current_paths(sd_journal *j) {
* treat them as fatal. */
ORDERED_HASHMAP_FOREACH(f, j->files) {
- _cleanup_free_ char *dir;
+ _cleanup_free_ char *dir = NULL;
int r;
dir = dirname_malloc(f->path);
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index a3da2e3f24..b4e010e74c 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -775,7 +775,7 @@ _public_ int sd_get_sessions(char ***sessions) {
}
_public_ int sd_get_uids(uid_t **users) {
- _cleanup_closedir_ DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
unsigned n = 0;
diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c
index e8de1b789a..d2f0566dbc 100644
--- a/src/locale/keymap-util.c
+++ b/src/locale/keymap-util.c
@@ -535,7 +535,7 @@ int vconsole_convert_to_x11(Context *c) {
int find_converted_keymap(const char *x11_layout, const char *x11_variant, char **new_keymap) {
const char *dir;
- _cleanup_free_ char *n;
+ _cleanup_free_ char *n = NULL;
if (x11_variant)
n = strjoin(x11_layout, "-", x11_variant);
diff --git a/src/locale/localed.c b/src/locale/localed.c
index 953cf6a0d7..df0eb030d4 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -457,7 +457,7 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
(void) locale_update_system_manager(c, sd_bus_message_get_bus(m));
if (settings) {
- _cleanup_free_ char *line;
+ _cleanup_free_ char *line = NULL;
line = strv_join(settings, ", ");
log_info("Changed locale to %s.", strnull(line));
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 2ecf2120fd..cd3a374201 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -485,7 +485,7 @@ int config_parse_n_autovts(
static int vt_is_busy(unsigned vtnr) {
struct vt_stat vt_stat;
int r;
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
assert(vtnr >= 1);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 694a99fba1..feeacc2d99 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1371,7 +1371,7 @@ static int attach_device(Manager *m, const char *seat, const char *sysfs) {
}
static int flush_devices(Manager *m) {
- _cleanup_closedir_ DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
assert(m);
@@ -2073,7 +2073,7 @@ static int update_schedule_file(Manager *m) {
m->scheduled_shutdown_type);
if (!isempty(m->wall_message)) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = cescape(m->wall_message);
if (!t) {
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 34fcde92aa..6a3dd860db 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -266,7 +266,7 @@ int session_save(Session *s) {
fprintf(f, "DISPLAY=%s\n", s->display);
if (s->remote_host) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_host);
if (!escaped) {
@@ -278,7 +278,7 @@ int session_save(Session *s) {
}
if (s->remote_user) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->remote_user);
if (!escaped) {
@@ -290,7 +290,7 @@ int session_save(Session *s) {
}
if (s->service) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->service);
if (!escaped) {
@@ -302,7 +302,7 @@ int session_save(Session *s) {
}
if (s->desktop) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(s->desktop);
if (!escaped) {
diff --git a/src/machine/machine.c b/src/machine/machine.c
index 537b0cd779..6215b29c27 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -134,7 +134,7 @@ int machine_save(Machine *m) {
m->name);
if (m->unit) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->unit);
if (!escaped) {
@@ -149,7 +149,7 @@ int machine_save(Machine *m) {
fprintf(f, "SCOPE_JOB=%s\n", m->scope_job);
if (m->service) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->service);
if (!escaped) {
@@ -160,7 +160,7 @@ int machine_save(Machine *m) {
}
if (m->root_directory) {
- _cleanup_free_ char *escaped;
+ _cleanup_free_ char *escaped = NULL;
escaped = cescape(m->root_directory);
if (!escaped) {
diff --git a/src/network/netdev/tuntap.c b/src/network/netdev/tuntap.c
index d9d654495e..0e13c4f88a 100644
--- a/src/network/netdev/tuntap.c
+++ b/src/network/netdev/tuntap.c
@@ -46,7 +46,7 @@ static int netdev_fill_tuntap_message(NetDev *netdev, struct ifreq *ifr) {
}
static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
- _cleanup_close_ int fd;
+ _cleanup_close_ int fd = -1;
TunTap *t = NULL;
const char *user;
const char *group;
diff --git a/src/network/wait-online/wait-online.c b/src/network/wait-online/wait-online.c
index ca0116e7f3..98480a6c65 100644
--- a/src/network/wait-online/wait-online.c
+++ b/src/network/wait-online/wait-online.c
@@ -53,7 +53,7 @@ static int help(void) {
static int parse_interface_with_operstate_range(const char *str) {
_cleanup_free_ char *ifname = NULL;
- _cleanup_free_ LinkOperationalStateRange *range;
+ _cleanup_free_ LinkOperationalStateRange *range = NULL;
const char *p;
int r;
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 02d1d64195..e2bce27947 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -861,7 +861,7 @@ static int find_profile(const char *name, const char *unit, char **ret) {
assert_se(dot = strrchr(unit, '.'));
NULSTR_FOREACH(p, profile_dirs) {
- _cleanup_free_ char *joined;
+ _cleanup_free_ char *joined = NULL;
joined = strjoin(p, "/", name, "/", dot + 1, ".conf");
if (!joined)
diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c
index fa6df9054a..2d8079ad97 100644
--- a/src/portable/portablectl.c
+++ b/src/portable/portablectl.c
@@ -341,7 +341,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
nl = true;
} else {
_cleanup_free_ char *pretty_portable = NULL, *pretty_os = NULL;
- _cleanup_fclose_ FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
f = fmemopen_unlocked((void*) data, sz, "re");
if (!f)
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 81c62bdca6..e155df0efa 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -1447,7 +1447,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
/* Since all the active services are in the zone make them discoverable now. */
SET_FOREACH(service_type, types) {
- _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr;
+ _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR,
"_services._dns-sd._udp.local");
diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c
index ef4b88361f..10e1857649 100644
--- a/src/shared/acl-util.c
+++ b/src/shared/acl-util.c
@@ -211,7 +211,7 @@ int acl_search_groups(const char *path, char ***ret_groups) {
int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want_mask) {
_cleanup_free_ char **a = NULL, **d = NULL; /* strings are not freed */
- _cleanup_strv_free_ char **split;
+ _cleanup_strv_free_ char **split = NULL;
char **entry;
int r = -EINVAL;
_cleanup_(acl_freep) acl_t a_acl = NULL, d_acl = NULL;
@@ -233,7 +233,7 @@ int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want
}
if (!strv_isempty(a)) {
- _cleanup_free_ char *join;
+ _cleanup_free_ char *join = NULL;
join = strv_join(a, ",");
if (!join)
@@ -251,7 +251,7 @@ int parse_acl(const char *text, acl_t *acl_access, acl_t *acl_default, bool want
}
if (!strv_isempty(d)) {
- _cleanup_free_ char *join;
+ _cleanup_free_ char *join = NULL;
join = strv_join(d, ",");
if (!join)
diff --git a/src/shared/bus-wait-for-jobs.c b/src/shared/bus-wait-for-jobs.c
index 51b71ecc2c..e66c8beafa 100644
--- a/src/shared/bus-wait-for-jobs.c
+++ b/src/shared/bus-wait-for-jobs.c
@@ -184,7 +184,7 @@ static void log_job_error_with_service_result(const char* service, const char *r
service_shell_quoted = shell_maybe_quote(service, ESCAPE_BACKSLASH);
if (!strv_isempty((char**) extra_args)) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = strv_join((char**) extra_args, " ");
systemctl = strjoina("systemctl ", t ? : "<args>");
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c
index 77fe227e36..497b0884d4 100644
--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -240,7 +240,7 @@ static int clean_posix_shm_internal(const char *dirname, DIR *dir, uid_t uid, gi
}
if (S_ISDIR(st.st_mode)) {
- _cleanup_closedir_ DIR *kid;
+ _cleanup_closedir_ DIR *kid = NULL;
kid = xopendirat(dirfd(dir), de->d_name, O_NOFOLLOW|O_NOATIME);
if (!kid) {
diff --git a/src/shared/clock-util.c b/src/shared/clock-util.c
index ec67b054b4..b446daf581 100644
--- a/src/shared/clock-util.c
+++ b/src/shared/clock-util.c
@@ -55,7 +55,7 @@ int clock_set_hwclock(const struct tm *tm) {
}
int clock_is_localtime(const char* adjtime_path) {
- _cleanup_fclose_ FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
int r;
if (!adjtime_path)
diff --git a/src/shared/format-table.c b/src/shared/format-table.c
index abc4bb3651..76cf3343db 100644
--- a/src/shared/format-table.c
+++ b/src/shared/format-table.c
@@ -1409,7 +1409,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
case TABLE_TIMESTAMP:
case TABLE_TIMESTAMP_UTC:
case TABLE_TIMESTAMP_RELATIVE: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
char *ret;
p = new(char, FORMAT_TIMESTAMP_MAX);
@@ -1431,7 +1431,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
case TABLE_TIMESPAN:
case TABLE_TIMESPAN_MSEC: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, FORMAT_TIMESPAN_MAX);
if (!p)
@@ -1446,7 +1446,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_SIZE: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, FORMAT_BYTES_MAX);
if (!p)
@@ -1460,7 +1460,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_BPS: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
size_t n;
p = new(char, FORMAT_BYTES_MAX+2);
@@ -1478,7 +1478,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_INT: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int_val) + 1);
if (!p)
@@ -1490,7 +1490,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_INT8: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int8) + 1);
if (!p)
@@ -1502,7 +1502,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_INT16: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int16) + 1);
if (!p)
@@ -1514,7 +1514,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_INT32: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int32) + 1);
if (!p)
@@ -1526,7 +1526,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_INT64: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->int64) + 1);
if (!p)
@@ -1538,7 +1538,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_UINT: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint_val) + 1);
if (!p)
@@ -1550,7 +1550,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_UINT8: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint8) + 1);
if (!p)
@@ -1562,7 +1562,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_UINT16: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint16) + 1);
if (!p)
@@ -1574,7 +1574,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_UINT32: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint32) + 1);
if (!p)
@@ -1586,7 +1586,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_UINT64: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->uint64) + 1);
if (!p)
@@ -1598,7 +1598,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
}
case TABLE_PERCENT: {
- _cleanup_free_ char *p;
+ _cleanup_free_ char *p = NULL;
p = new(char, DECIMAL_STR_WIDTH(d->percent) + 2);
if (!p)
diff --git a/src/shared/install.c b/src/shared/install.c
index c6cea43126..eb8d7c1c45 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -2950,7 +2950,7 @@ static int read_presets(UnitFileScope scope, const char *root_dir, UnitFilePrese
return r;
STRV_FOREACH(p, files) {
- _cleanup_fclose_ FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
int n = 0;
f = fopen(*p, "re");
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 706a00c7f0..e63c59bd94 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -294,7 +294,7 @@ static bool print_multiline(
continuation * prefix, "",
color_on, len, pos, color_off);
else {
- _cleanup_free_ char *e;
+ _cleanup_free_ char *e = NULL;
e = ellipsize_mem(pos, len, n_columns - prefix,
tail_line ? 100 : 90);
@@ -1651,7 +1651,7 @@ int show_journal_by_unit(
return r;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *filter;
+ _cleanup_free_ char *filter = NULL;
filter = journal_make_match_string(j);
if (!filter)
diff --git a/src/shared/net-condition.c b/src/shared/net-condition.c
index 174bb2a7ea..2479a5672c 100644
--- a/src/shared/net-condition.c
+++ b/src/shared/net-condition.c
@@ -147,7 +147,7 @@ bool net_match_config(
const char *ssid,
const struct ether_addr *bssid) {
- _cleanup_free_ char *iftype_str;
+ _cleanup_free_ char *iftype_str = NULL;
const char *path = NULL;
assert(match);
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index 37f83306db..53280cf40a 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -34,7 +34,7 @@
#include "time-util.h"
int parse_sleep_config(SleepConfig **ret_sleep_config) {
- _cleanup_(free_sleep_configp) SleepConfig *sc;
+ _cleanup_(free_sleep_configp) SleepConfig *sc = NULL;
int allow_suspend = -1, allow_hibernate = -1,
allow_s2h = -1, allow_hybrid_sleep = -1;
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
index 314962ac69..6e7c67ef2f 100644
--- a/src/systemctl/systemctl-edit.c
+++ b/src/systemctl/systemctl-edit.c
@@ -576,7 +576,7 @@ end:
/* Removing empty dropin dirs */
if (!arg_full) {
- _cleanup_free_ char *dir;
+ _cleanup_free_ char *dir = NULL;
dir = dirname_malloc(*original);
if (!dir)
diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c
index e02a7608fe..135d8388a3 100644
--- a/src/systemctl/systemctl-list-units.c
+++ b/src/systemctl/systemctl-list-units.c
@@ -24,7 +24,7 @@ static int get_unit_list_recursive(
char ***ret_machines) {
_cleanup_free_ UnitInfo *unit_infos = NULL;
- _cleanup_(message_set_freep) Set *replies;
+ _cleanup_(message_set_freep) Set *replies = NULL;
sd_bus_message *reply;
int c, r;
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 2fe3d8c509..1a0bd35617 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -1282,7 +1282,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m
while ((r = exec_status_info_deserialize(m, &info, is_ex_prop)) > 0) {
char timestamp1[FORMAT_TIMESTAMP_MAX], timestamp2[FORMAT_TIMESTAMP_MAX];
_cleanup_strv_free_ char **optv = NULL;
- _cleanup_free_ char *tt, *o = NULL;
+ _cleanup_free_ char *tt = NULL, *o = NULL;
tt = strv_join(info.argv, " ");
@@ -2129,7 +2129,7 @@ int show(int argc, char *argv[], void *userdata) {
return r;
STRV_FOREACH(name, names) {
- _cleanup_free_ char *path;
+ _cleanup_free_ char *path = NULL;
path = unit_dbus_path_from_name(*name);
if (!path)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 8c7aef23c3..cef141fbac 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -137,7 +137,7 @@ static int generate_unit_file(SysvStub *s) {
path_escaped);
if (s->description) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = specifier_escape(s->description);
if (!t)
@@ -165,7 +165,7 @@ static int generate_unit_file(SysvStub *s) {
yes_no(!s->pid_file));
if (s->pid_file) {
- _cleanup_free_ char *t;
+ _cleanup_free_ char *t = NULL;
t = specifier_escape(s->pid_file);
if (!t)
@@ -419,7 +419,7 @@ static int handle_dependencies(SysvStub *s, unsigned line, const char *full_text
}
static int load_sysv(SysvStub *s) {
- _cleanup_fclose_ FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
unsigned line = 0;
int r;
enum {
diff --git a/src/timesync/wait-sync.c b/src/timesync/wait-sync.c
index df34541bf7..2a9b113ff4 100644
--- a/src/timesync/wait-sync.c
+++ b/src/timesync/wait-sync.c
@@ -179,7 +179,7 @@ static int clock_state_update(
}
static int run(int argc, char * argv[]) {
- _cleanup_(sd_event_unrefp) sd_event *event;
+ _cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(clock_state_release) ClockState state = {
.timerfd_fd = -1,
.inotify_fd = -1,
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 5ee82c708b..ceacb61bf1 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -289,7 +289,7 @@ static int wall_tty_block(void) {
}
static int process_password_files(void) {
- _cleanup_closedir_ DIR *d;
+ _cleanup_closedir_ DIR *d = NULL;
struct dirent *de;
int r = 0;
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index 2f07a2d99f..d9d897c00c 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -106,7 +106,7 @@ static int get_file_options(const char *vendor, const char *model,
int *argc, char ***newargv) {
_cleanup_free_ char *vendor_in = NULL, *model_in = NULL, *options_in = NULL; /* read in from file */
_cleanup_strv_free_ char **options_argv = NULL;
- _cleanup_fclose_ FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
int lineno, r;
f = fopen(config_file, "re");
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index 45915ef853..d1c3febdd5 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -146,7 +146,7 @@ static int keyboard_load_and_wait(const char *vc, const char *map, const char *m
args[i++] = NULL;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *cmd;
+ _cleanup_free_ char *cmd = NULL;
cmd = strv_join((char**) args, " ");
log_debug("Executing \"%s\"...", strnull(cmd));
@@ -189,7 +189,7 @@ static int font_load_and_wait(const char *vc, const char *font, const char *map,
args[i++] = NULL;
if (DEBUG_LOGGING) {
- _cleanup_free_ char *cmd;
+ _cleanup_free_ char *cmd = NULL;
cmd = strv_join((char**) args, " ");
log_debug("Executing \"%s\"...", strnull(cmd));