1abbee
From c815acfb5863d9562a3f1e9cbd6204da3364860c Mon Sep 17 00:00:00 2001
1abbee
From: Harald Hoyer <harald@redhat.com>
1abbee
Date: Fri, 27 Mar 2015 12:02:49 +0100
1abbee
Subject: [PATCH] fix gcc warnings about uninitialized variables
1abbee
MIME-Version: 1.0
1abbee
Content-Type: text/plain; charset=UTF-8
1abbee
Content-Transfer-Encoding: 8bit
1abbee
1abbee
like:
1abbee
1abbee
src/shared/install.c: In function ‘unit_file_lookup_state’:
1abbee
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
1abbee
this function [-Wmaybe-uninitialized]
1abbee
         return r < 0 ? r : state;
1abbee
                ^
1abbee
src/shared/install.c:1796:13: note: ‘r’ was declared here
1abbee
         int r;
1abbee
             ^
1abbee
1abbee
Conflicts:
1abbee
	src/journal/journal-file.c
1abbee
	src/shared/btrfs-util.c
1abbee
        src/shared/install.c
1abbee
1abbee
Cherry-picked from: a7f7d1bde43fc825c49afea3f946f5b4b3d563e0
1abbee
Related: #1318994
1abbee
---
1abbee
 src/import/import-job.c                   | 2 +-
1abbee
 src/journal-remote/journal-gatewayd.c     | 2 +-
1abbee
 src/journal-remote/journal-remote-parse.c | 2 +-
1abbee
 src/journal-remote/journal-remote.c       | 4 ++--
1abbee
 src/journal/catalog.c                     | 2 +-
1abbee
 src/journal/coredump.c                    | 4 ++--
1abbee
 src/journal/journal-file.c                | 6 +++---
1abbee
 src/journal/journal-vacuum.c              | 2 +-
1abbee
 src/journal/journalctl.c                  | 2 +-
1abbee
 src/journal/test-journal-stream.c         | 2 +-
1abbee
 src/libsystemd-network/lldp-tlv.c         | 8 ++++----
1abbee
 src/libsystemd-network/sd-dhcp-server.c   | 2 +-
1abbee
 src/libsystemd-network/sd-pppoe.c         | 2 +-
1abbee
 src/libsystemd/sd-login/sd-login.c        | 2 +-
1abbee
 src/network/networkctl.c                  | 2 +-
1abbee
 src/resolve/resolved-dns-transaction.c    | 2 +-
1abbee
 src/resolve/test-dns-domain.c             | 2 +-
1abbee
 src/shared/base-filesystem.c              | 2 +-
1abbee
 src/shared/capability.c                   | 2 +-
1abbee
 src/shared/copy.c                         | 6 +++---
1abbee
 src/shared/install.c                      | 2 +-
1abbee
 src/shared/logs-show.c                    | 2 +-
1abbee
 src/shared/util.c                         | 4 ++--
1abbee
 src/test/test-path.c                      | 2 +-
1abbee
 src/test/test-pty.c                       | 2 +-
1abbee
 src/udev/net/link-config.c                | 2 +-
1abbee
 26 files changed, 36 insertions(+), 36 deletions(-)
1abbee
1abbee
diff --git a/src/import/import-job.c b/src/import/import-job.c
c62b8e
index 5f9cfd366d..d826f493f8 100644
1abbee
--- a/src/import/import-job.c
1abbee
+++ b/src/import/import-job.c
1abbee
@@ -80,7 +80,7 @@ void import_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
1abbee
         long status;
1abbee
         int r;
1abbee
 
1abbee
-        if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, &j) != CURLE_OK)
1abbee
+        if (curl_easy_getinfo(curl, CURLINFO_PRIVATE, (char **)&j) != CURLE_OK)
1abbee
                 return;
1abbee
 
1abbee
         if (!j || j->state == IMPORT_JOB_DONE || j->state == IMPORT_JOB_FAILED)
1abbee
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
c62b8e
index 576f7cae7d..d1f0ce3da3 100644
1abbee
--- a/src/journal-remote/journal-gatewayd.c
1abbee
+++ b/src/journal-remote/journal-gatewayd.c
1abbee
@@ -736,7 +736,7 @@ static int request_handler_machine(
1abbee
         RequestMeta *m = connection_cls;
1abbee
         int r;
1abbee
         _cleanup_free_ char* hostname = NULL, *os_name = NULL;
1abbee
-        uint64_t cutoff_from = 0, cutoff_to = 0, usage;
1abbee
+        uint64_t cutoff_from = 0, cutoff_to = 0, usage = 0;
1abbee
         char *json;
1abbee
         sd_id128_t mid, bid;
1abbee
         _cleanup_free_ char *v = NULL;
1abbee
diff --git a/src/journal-remote/journal-remote-parse.c b/src/journal-remote/journal-remote-parse.c
c62b8e
index 7e62954351..64089da19b 100644
1abbee
--- a/src/journal-remote/journal-remote-parse.c
1abbee
+++ b/src/journal-remote/journal-remote-parse.c
1abbee
@@ -316,7 +316,7 @@ int process_data(RemoteSource *source) {
1abbee
         switch(source->state) {
1abbee
         case STATE_LINE: {
1abbee
                 char *line, *sep;
1abbee
-                size_t n;
1abbee
+                size_t n = 0;
1abbee
 
1abbee
                 assert(source->data_size == 0);
1abbee
 
1abbee
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
c62b8e
index 9c515f9c8f..4fac55cc9a 100644
1abbee
--- a/src/journal-remote/journal-remote.c
1abbee
+++ b/src/journal-remote/journal-remote.c
1abbee
@@ -353,7 +353,7 @@ static int remove_source(RemoteServer *s, int fd) {
1abbee
 
1abbee
 static int add_source(RemoteServer *s, int fd, char* name, bool own_name) {
1abbee
 
1abbee
-        RemoteSource *source;
1abbee
+        RemoteSource *source = NULL;
1abbee
         int r;
1abbee
 
1abbee
         /* This takes ownership of name, even on failure, if own_name is true. */
1abbee
@@ -1148,7 +1148,7 @@ static int dispatch_raw_connection_event(sd_event_source *event,
1abbee
                 .size = sizeof(union sockaddr_union),
1abbee
                 .type = SOCK_STREAM,
1abbee
         };
1abbee
-        char *hostname;
1abbee
+        char *hostname = NULL;
1abbee
 
1abbee
         fd2 = accept_connection("raw", fd, &addr, &hostname);
1abbee
         if (fd2 < 0)
1abbee
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
c62b8e
index f170232841..a9c40c6d4f 100644
1abbee
--- a/src/journal/catalog.c
1abbee
+++ b/src/journal/catalog.c
1abbee
@@ -559,7 +559,7 @@ static const char *find_id(void *p, sd_id128_t id) {
1abbee
 int catalog_get(const char* database, sd_id128_t id, char **_text) {
1abbee
         _cleanup_close_ int fd = -1;
1abbee
         void *p = NULL;
1abbee
-        struct stat st;
1abbee
+        struct stat st = {};
1abbee
         char *text = NULL;
1abbee
         int r;
1abbee
         const char *s;
1abbee
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
c62b8e
index f7ba0191e1..59ccd46bb0 100644
1abbee
--- a/src/journal/coredump.c
1abbee
+++ b/src/journal/coredump.c
1abbee
@@ -244,7 +244,7 @@ static int maybe_remove_external_coredump(const char *filename, off_t size) {
1abbee
 
1abbee
 static int make_filename(const char *info[_INFO_LEN], char **ret) {
1abbee
         _cleanup_free_ char *c = NULL, *u = NULL, *p = NULL, *t = NULL;
1abbee
-        sd_id128_t boot;
1abbee
+        sd_id128_t boot = {};
1abbee
         int r;
1abbee
 
1abbee
         assert(info);
1abbee
@@ -843,7 +843,7 @@ log:
1abbee
         /* Optionally store the entire coredump in the journal */
1abbee
         if (IN_SET(arg_storage, COREDUMP_STORAGE_JOURNAL, COREDUMP_STORAGE_BOTH) &&
1abbee
             coredump_size <= (off_t) arg_journal_size_max) {
1abbee
-                size_t sz;
1abbee
+                size_t sz = 0;
1abbee
 
1abbee
                 /* Store the coredump itself in the journal */
1abbee
 
1abbee
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
c62b8e
index ef18497879..2a93460d4e 100644
1abbee
--- a/src/journal/journal-file.c
1abbee
+++ b/src/journal/journal-file.c
1abbee
@@ -911,7 +911,7 @@ int journal_file_find_data_object_with_hash(
1abbee
                 if (o->object.flags & OBJECT_COMPRESSION_MASK) {
1abbee
 #if defined(HAVE_XZ) || defined(HAVE_LZ4)
1abbee
                         uint64_t l;
1abbee
-                        size_t rsize;
1abbee
+                        size_t rsize = 0;
1abbee
 
1abbee
                         l = le64toh(o->object.size);
1abbee
                         if (l <= offsetof(Object, data.payload))
1abbee
@@ -1075,7 +1075,7 @@ static int journal_file_append_data(
1abbee
 
1abbee
 #if defined(HAVE_XZ) || defined(HAVE_LZ4)
1abbee
         if (JOURNAL_FILE_COMPRESS(f) && size >= COMPRESSION_SIZE_THRESHOLD) {
1abbee
-                size_t rsize;
1abbee
+                size_t rsize = 0;
1abbee
 
1abbee
                 compression = compress_blob(data, size, o->data.payload, &rsize);
1abbee
 
1abbee
@@ -2903,7 +2903,7 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
1abbee
 
1abbee
                 if (o->object.flags & OBJECT_COMPRESSION_MASK) {
1abbee
 #if defined(HAVE_XZ) || defined(HAVE_LZ4)
1abbee
-                        size_t rsize;
1abbee
+                        size_t rsize = 0;
1abbee
 
1abbee
                         r = decompress_blob(o->object.flags & OBJECT_COMPRESSION_MASK,
1abbee
                                             o->data.payload, l, &from->compress_buffer, &from->compress_buffer_size, &rsize, 0);
1abbee
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
c62b8e
index 832c327b31..856d11e4ed 100644
1abbee
--- a/src/journal/journal-vacuum.c
1abbee
+++ b/src/journal/journal-vacuum.c
1abbee
@@ -76,7 +76,7 @@ static void patch_realtime(
1abbee
                 unsigned long long *realtime) {
1abbee
 
1abbee
         _cleanup_free_ const char *path = NULL;
1abbee
-        usec_t x, crtime;
1abbee
+        usec_t x, crtime = 0;
1abbee
 
1abbee
         /* The timestamp was determined by the file name, but let's
1abbee
          * see if the file might actually be older than the file name
1abbee
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
c62b8e
index a38ce4b8fd..6ba8847798 100644
1abbee
--- a/src/journal/journalctl.c
1abbee
+++ b/src/journal/journalctl.c
1abbee
@@ -1644,7 +1644,7 @@ static int verify(sd_journal *j) {
1abbee
 
1abbee
         ORDERED_HASHMAP_FOREACH(f, j->files, i) {
1abbee
                 int k;
1abbee
-                usec_t first, validated, last;
1abbee
+                usec_t first = 0, validated = 0, last = 0;
1abbee
 
1abbee
 #ifdef HAVE_GCRYPT
1abbee
                 if (!arg_verify_key && JOURNAL_HEADER_SEALED(f->header))
1abbee
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
c62b8e
index 3996e778e6..b8caeb3d41 100644
1abbee
--- a/src/journal/test-journal-stream.c
1abbee
+++ b/src/journal/test-journal-stream.c
1abbee
@@ -42,7 +42,7 @@ static void verify_contents(sd_journal *j, unsigned skip) {
1abbee
                 const void *d;
1abbee
                 char *k, *c;
1abbee
                 size_t l;
1abbee
-                unsigned u;
1abbee
+                unsigned u = 0;
1abbee
 
1abbee
                 assert_se(sd_journal_get_cursor(j, &k) >= 0);
1abbee
                 printf("cursor: %s\n", k);
1abbee
diff --git a/src/libsystemd-network/lldp-tlv.c b/src/libsystemd-network/lldp-tlv.c
c62b8e
index e43d70d3cf..e32783f3eb 100644
1abbee
--- a/src/libsystemd-network/lldp-tlv.c
1abbee
+++ b/src/libsystemd-network/lldp-tlv.c
1abbee
@@ -156,7 +156,7 @@ static inline int tlv_packet_read_internal(tlv_section *m, void **data) {
1abbee
 }
1abbee
 
1abbee
 int tlv_packet_read_u8(tlv_packet *m, uint8_t *data) {
1abbee
-        void *val;
1abbee
+        void *val = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert_return(m, -EINVAL);
1abbee
@@ -174,7 +174,7 @@ int tlv_packet_read_u8(tlv_packet *m, uint8_t *data) {
1abbee
 
1abbee
 int tlv_packet_read_u16(tlv_packet *m, uint16_t *data) {
1abbee
         uint16_t t;
1abbee
-        void *val;
1abbee
+        void *val = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert_return(m, -EINVAL);
1abbee
@@ -211,7 +211,7 @@ int tlv_packet_read_u32(tlv_packet *m, uint32_t *data) {
1abbee
 }
1abbee
 
1abbee
 int tlv_packet_read_string(tlv_packet *m, char **data, uint16_t *data_length) {
1abbee
-        void *val;
1abbee
+        void *val = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert_return(m, -EINVAL);
1abbee
@@ -229,7 +229,7 @@ int tlv_packet_read_string(tlv_packet *m, char **data, uint16_t *data_length) {
1abbee
 }
1abbee
 
1abbee
 int tlv_packet_read_bytes(tlv_packet *m, uint8_t **data, uint16_t *data_length) {
1abbee
-        void *val;
1abbee
+        void *val = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert_return(m, -EINVAL);
1abbee
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
c62b8e
index 3f89f344d7..0f284eb6a1 100644
1abbee
--- a/src/libsystemd-network/sd-dhcp-server.c
1abbee
+++ b/src/libsystemd-network/sd-dhcp-server.c
1abbee
@@ -776,7 +776,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
1abbee
                 if (pool_offset >= 0 &&
1abbee
                     server->bound_leases[pool_offset] == existing_lease) {
1abbee
                         DHCPLease *lease;
1abbee
-                        usec_t time_now;
1abbee
+                        usec_t time_now = 0;
1abbee
 
1abbee
                         if (!existing_lease) {
1abbee
                                 lease = new0(DHCPLease, 1);
1abbee
diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c
c62b8e
index 4f49b799ec..83e58a3db3 100644
1abbee
--- a/src/libsystemd-network/sd-pppoe.c
1abbee
+++ b/src/libsystemd-network/sd-pppoe.c
1abbee
@@ -340,7 +340,7 @@ static int pppoe_timeout(sd_event_source *s, uint64_t usec, void *userdata);
1abbee
 
1abbee
 static int pppoe_arm_timeout(sd_pppoe *ppp) {
1abbee
         _cleanup_event_source_unref_ sd_event_source *timeout = NULL;
1abbee
-        usec_t next_timeout;
1abbee
+        usec_t next_timeout = 0;
1abbee
         int r;
1abbee
 
1abbee
         assert(ppp);
1abbee
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
c62b8e
index f71749f72d..cc0677bdf2 100644
1abbee
--- a/src/libsystemd/sd-login/sd-login.c
1abbee
+++ b/src/libsystemd/sd-login/sd-login.c
1abbee
@@ -82,7 +82,7 @@ _public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
1abbee
 }
1abbee
 
1abbee
 _public_ int sd_peer_get_session(int fd, char **session) {
1abbee
-        struct ucred ucred;
1abbee
+        struct ucred ucred = {};
1abbee
         int r;
1abbee
 
1abbee
         assert_return(fd >= 0, -EINVAL);
1abbee
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
c62b8e
index aa83f32f53..778670b733 100644
1abbee
--- a/src/network/networkctl.c
1abbee
+++ b/src/network/networkctl.c
1abbee
@@ -964,7 +964,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
1abbee
                                                 return -ENOMEM;
1abbee
 
1abbee
                                 } else if (streq(a, "_TTL")) {
1abbee
-                                        long long unsigned x;
1abbee
+                                        long long unsigned x = 0;
1abbee
                                         usec_t time;
1abbee
 
1abbee
                                         r = safe_atollu(b, &x);
1abbee
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
c62b8e
index 74b0634142..bc1a90db1b 100644
1abbee
--- a/src/resolve/resolved-dns-transaction.c
1abbee
+++ b/src/resolve/resolved-dns-transaction.c
1abbee
@@ -252,7 +252,7 @@ static int dns_transaction_open_tcp(DnsTransaction *t) {
1abbee
                         fd = dns_scope_tcp_socket(t->scope, t->received->family, &t->received->sender, t->received->sender_port);
1abbee
                 else {
1abbee
                         union in_addr_union address;
1abbee
-                        int family;
1abbee
+                        int family = AF_UNSPEC;
1abbee
 
1abbee
                         /* Otherwise, try to talk to the owner of a
1abbee
                          * the IP address, in case this is a reverse
1abbee
diff --git a/src/resolve/test-dns-domain.c b/src/resolve/test-dns-domain.c
c62b8e
index ebc8d98fce..4963a9c6a5 100644
1abbee
--- a/src/resolve/test-dns-domain.c
1abbee
+++ b/src/resolve/test-dns-domain.c
1abbee
@@ -162,7 +162,7 @@ static void test_dns_name_single_label(void) {
1abbee
 
1abbee
 static void test_dns_name_reverse_one(const char *address, const char *name) {
1abbee
         _cleanup_free_ char *p = NULL;
1abbee
-        union in_addr_union a, b;
1abbee
+        union in_addr_union a, b = {};
1abbee
         int familya, familyb;
1abbee
 
1abbee
         assert_se(in_addr_from_string_auto(address, &familya, &a) >= 0);
1abbee
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
c62b8e
index 73907c6354..20a69bdbff 100644
1abbee
--- a/src/shared/base-filesystem.c
1abbee
+++ b/src/shared/base-filesystem.c
1abbee
@@ -55,7 +55,7 @@ static const BaseFilesystem table[] = {
1abbee
 int base_filesystem_create(const char *root) {
1abbee
         _cleanup_close_ int fd = -1;
1abbee
         unsigned i;
1abbee
-        int r;
1abbee
+        int r = 0;
1abbee
 
1abbee
         fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
1abbee
         if (fd < 0)
1abbee
diff --git a/src/shared/capability.c b/src/shared/capability.c
c62b8e
index 915ceb9d9b..2b963fde3f 100644
1abbee
--- a/src/shared/capability.c
1abbee
+++ b/src/shared/capability.c
1abbee
@@ -55,7 +55,7 @@ unsigned long cap_last_cap(void) {
1abbee
         static thread_local unsigned long saved;
1abbee
         static thread_local bool valid = false;
1abbee
         _cleanup_free_ char *content = NULL;
1abbee
-        unsigned long p;
1abbee
+        unsigned long p = 0;
1abbee
         int r;
1abbee
 
1abbee
         if (valid)
1abbee
diff --git a/src/shared/copy.c b/src/shared/copy.c
c62b8e
index 0239a58066..2a0cb28080 100644
1abbee
--- a/src/shared/copy.c
1abbee
+++ b/src/shared/copy.c
1abbee
@@ -360,7 +360,7 @@ int copy_file_fd(const char *from, int fdt, bool try_reflink) {
1abbee
 }
1abbee
 
1abbee
 int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned chattr_flags) {
1abbee
-        int fdt, r;
1abbee
+        int fdt = -1, r;
1abbee
 
1abbee
         assert(from);
1abbee
         assert(to);
1abbee
@@ -390,7 +390,7 @@ int copy_file(const char *from, const char *to, int flags, mode_t mode, unsigned
1abbee
 }
1abbee
 
1abbee
 int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace, unsigned chattr_flags) {
1abbee
-        _cleanup_free_ char *t;
1abbee
+        _cleanup_free_ char *t = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert(from);
1abbee
@@ -415,7 +415,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
1abbee
 int copy_times(int fdf, int fdt) {
1abbee
         struct timespec ut[2];
1abbee
         struct stat st;
1abbee
-        usec_t crtime;
1abbee
+        usec_t crtime = 0;
1abbee
 
1abbee
         assert(fdf >= 0);
1abbee
         assert(fdt >= 0);
1abbee
diff --git a/src/shared/install.c b/src/shared/install.c
c62b8e
index 9962508b1a..61aaafe7bc 100644
1abbee
--- a/src/shared/install.c
1abbee
+++ b/src/shared/install.c
1abbee
@@ -2046,7 +2046,7 @@ UnitFileState unit_file_lookup_state(
1abbee
         _cleanup_(install_context_done) InstallContext c = {};
1abbee
         InstallInfo *i;
1abbee
         UnitFileState state;
1abbee
-        int r;
1abbee
+        int r = 0;
1abbee
 
1abbee
         assert(paths);
1abbee
         assert(name);
1abbee
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
c62b8e
index 8c374116ad..a572be94b4 100644
1abbee
--- a/src/shared/logs-show.c
1abbee
+++ b/src/shared/logs-show.c
1abbee
@@ -993,7 +993,7 @@ static int show_journal(FILE *f,
1abbee
 
1abbee
                 if (warn_cutoff && line < how_many && not_before > 0) {
1abbee
                         sd_id128_t boot_id;
1abbee
-                        usec_t cutoff;
1abbee
+                        usec_t cutoff = 0;
1abbee
 
1abbee
                         /* Check whether the cutoff line is too early */
1abbee
 
1abbee
diff --git a/src/shared/util.c b/src/shared/util.c
c62b8e
index 3030261524..4c441a5448 100644
1abbee
--- a/src/shared/util.c
1abbee
+++ b/src/shared/util.c
1abbee
@@ -3073,7 +3073,7 @@ int getttyname_malloc(int fd, char **ret) {
1abbee
 
1abbee
 int getttyname_harder(int fd, char **r) {
1abbee
         int k;
1abbee
-        char *s;
1abbee
+        char *s = NULL;
1abbee
 
1abbee
         k = getttyname_malloc(fd, &s);
1abbee
         if (k < 0)
1abbee
@@ -3627,7 +3627,7 @@ char **replace_env_argv(char **argv, char **env) {
1abbee
                 /* If $FOO appears as single word, replace it by the split up variable */
1abbee
                 if ((*i)[0] == '$' && (*i)[1] != '{') {
1abbee
                         char *e;
1abbee
-                        char **w, **m;
1abbee
+                        char **w, **m = NULL;
1abbee
                         unsigned q;
1abbee
 
1abbee
                         e = strv_env_get(env, *i+1);
1abbee
diff --git a/src/test/test-path.c b/src/test/test-path.c
c62b8e
index 4f9f5c1344..a3295aa997 100644
1abbee
--- a/src/test/test-path.c
1abbee
+++ b/src/test/test-path.c
1abbee
@@ -33,7 +33,7 @@ static int setup_test(Manager **m) {
1abbee
         char **tests_path = STRV_MAKE("exists", "existsglobFOOBAR", "changed", "modified", "unit",
1abbee
                                       "directorynotempty", "makedirectory");
1abbee
         char **test_path;
1abbee
-        Manager *tmp;
1abbee
+        Manager *tmp = NULL;
1abbee
         int r;
1abbee
 
1abbee
         assert_se(m);
1abbee
diff --git a/src/test/test-pty.c b/src/test/test-pty.c
c62b8e
index cab569a9da..67c125a4c0 100644
1abbee
--- a/src/test/test-pty.c
1abbee
+++ b/src/test/test-pty.c
1abbee
@@ -97,7 +97,7 @@ static void run_parent(Pty *pty) {
1abbee
 
1abbee
 static void test_pty(void) {
1abbee
         pid_t pid;
1abbee
-        Pty *pty;
1abbee
+        Pty *pty = NULL;
1abbee
 
1abbee
         rcvsiz = 0;
1abbee
         zero(rcvbuf);
1abbee
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
c62b8e
index 489593f4fd..ad6a82e506 100644
1abbee
--- a/src/udev/net/link-config.c
1abbee
+++ b/src/udev/net/link-config.c
1abbee
@@ -474,7 +474,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
1abbee
 
1abbee
 int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret) {
1abbee
         const char *name;
1abbee
-        char *driver;
1abbee
+        char *driver = NULL;
1abbee
         int r;
1abbee
 
1abbee
         name = udev_device_get_sysname(device);