From: Daan De Meyer Date: Tue, 23 May 2023 11:25:58 +0000 (+0200) Subject: tree-wide: Fix false positives on newer gcc X-Git-Tag: v254-rc1~407 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d41b6b8e864abbf7b81c938532f42e97a900e22;p=thirdparty%2Fsystemd.git tree-wide: Fix false positives on newer gcc Recent gcc versions have started to trigger false positive maybe-uninitialized warnings. Let's make sure we initialize variables annotated with _cleanup_ to avoid these. --- diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 802d9bf6f95..e1f0ff1dcbe 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -1230,7 +1230,7 @@ int home_setup_luks( PasswordCache *cache, UserRecord **ret_luks_home) { - sd_id128_t found_partition_uuid, found_fs_uuid, found_luks_uuid = SD_ID128_NULL; + sd_id128_t found_partition_uuid, found_fs_uuid = SD_ID128_NULL, found_luks_uuid = SD_ID128_NULL; _cleanup_(user_record_unrefp) UserRecord *luks_home = NULL; _cleanup_(erase_and_freep) void *volume_key = NULL; size_t volume_key_size = 0; diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c index 308569d786d..97cca9bf6a5 100644 --- a/src/journal/test-journal-interleaving.c +++ b/src/journal/test-journal-interleaving.c @@ -72,7 +72,7 @@ static void append_number(ManagedJournalFile *f, int n, uint64_t *seqnum) { static void test_check_number(sd_journal *j, int n) { const void *d; - _cleanup_free_ char *k; + _cleanup_free_ char *k = NULL; size_t l; int x; diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index e4354199e10..f3f558a3585 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsystemd-network/test-dhcp-client.c @@ -189,7 +189,7 @@ static int check_options(uint8_t code, uint8_t len, const void *option, void *us int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link, const void *packet, size_t len) { size_t size; - _cleanup_free_ DHCPPacket *discover; + _cleanup_free_ DHCPPacket *discover = NULL; uint16_t ip_check, udp_check; assert_se(s >= 0); diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index 9d5cab75b3a..8c6d59e0409 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -266,7 +266,7 @@ static void test_sd_device_enumerator_filter_subsystem_one( static bool test_sd_device_enumerator_filter_subsystem_trial(void) { _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; - _cleanup_(hashmap_freep) Hashmap *subsystems; + _cleanup_(hashmap_freep) Hashmap *subsystems = NULL; unsigned n_new_dev = 0, n_removed_dev = 0; sd_device *d; Hashmap *h; diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c index 4f61af50f33..7892f2bc2e3 100644 --- a/src/libsystemd/sd-event/test-event.c +++ b/src/libsystemd/sd-event/test-event.c @@ -506,7 +506,7 @@ static void test_inotify_one(unsigned n_create_events) { for (i = 0; i < n_create_events; i++) { char buf[DECIMAL_STR_MAX(unsigned)+1]; - _cleanup_free_ char *z; + _cleanup_free_ char *z = NULL; xsprintf(buf, "%u", i); assert_se(z = path_join(p, buf)); diff --git a/src/libsystemd/sd-journal/test-catalog.c b/src/libsystemd/sd-journal/test-catalog.c index 49185cc2b32..603952e904a 100644 --- a/src/libsystemd/sd-journal/test-catalog.c +++ b/src/libsystemd/sd-journal/test-catalog.c @@ -27,7 +27,7 @@ static const char *no_catalog_dirs[] = { static OrderedHashmap* test_import(const char* contents, ssize_t size, int code) { _cleanup_(unlink_tempfilep) char name[] = "/tmp/test-catalog.XXXXXX"; - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; OrderedHashmap *h; if (size < 0) diff --git a/src/libudev/test-libudev.c b/src/libudev/test-libudev.c index 94d34b1ae2e..839a6a1a742 100644 --- a/src/libudev/test-libudev.c +++ b/src/libudev/test-libudev.c @@ -91,7 +91,7 @@ static void print_device(struct udev_device *device) { } static void test_device(struct udev *udev, const char *syspath) { - _cleanup_(udev_device_unrefp) struct udev_device *device; + _cleanup_(udev_device_unrefp) struct udev_device *device = NULL; log_info("/* %s, device %s */", __func__, syspath); device = udev_device_new_from_syspath(udev, syspath); @@ -102,7 +102,7 @@ static void test_device(struct udev *udev, const char *syspath) { } static void test_device_parents(struct udev *udev, const char *syspath) { - _cleanup_(udev_device_unrefp) struct udev_device *device; + _cleanup_(udev_device_unrefp) struct udev_device *device = NULL; struct udev_device *device_parent; log_info("/* %s, device %s */", __func__, syspath); @@ -172,7 +172,7 @@ static int enumerate_print_list(struct udev_enumerate *enumerate) { static void test_monitor(struct udev *udev) { _cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor; - _cleanup_close_ int fd_ep; + _cleanup_close_ int fd_ep = -EBADF; int fd_udev; struct epoll_event ep_udev = { .events = EPOLLIN, diff --git a/src/resolve/test-resolved-etc-hosts.c b/src/resolve/test-resolved-etc-hosts.c index 19b2991a356..d46dbd30009 100644 --- a/src/resolve/test-resolved-etc-hosts.c +++ b/src/resolve/test-resolved-etc-hosts.c @@ -38,7 +38,7 @@ TEST(parse_etc_hosts) { t[] = "/tmp/test-resolved-etc-hosts.XXXXXX"; int fd; - _cleanup_fclose_ FILE *f; + _cleanup_fclose_ FILE *f = NULL; fd = mkostemp_safe(t); assert_se(fd >= 0); @@ -118,7 +118,7 @@ TEST(parse_etc_hosts) { static void test_parse_file_one(const char *fname) { _cleanup_(etc_hosts_clear) EtcHosts hosts = {}; - _cleanup_fclose_ FILE *f; + _cleanup_fclose_ FILE *f = NULL; log_info("/* %s(\"%s\") */", __func__, fname); diff --git a/src/test/test-bpf-devices.c b/src/test/test-bpf-devices.c index e1754837341..0e1287eac4e 100644 --- a/src/test/test-bpf-devices.c +++ b/src/test/test-bpf-devices.c @@ -37,7 +37,7 @@ static void test_policy_closed(const char *cgroup_path, BPFProgram **installed_p "/dev/urandom", "/dev/tty", "/dev/ptmx") { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); log_debug("open(%s, \"r\") = %d/%s", s, fd, fd < 0 ? errno_to_name(errno) : "-"); @@ -74,7 +74,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p assert_se(r >= 0); { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/null"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -87,7 +87,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p } { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/random"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -100,7 +100,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p } { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/zero"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -113,7 +113,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p } { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/full"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -146,7 +146,7 @@ static void test_policy_allow_list_major(const char *pattern, const char *cgroup /* /dev/null, /dev/full have major==1, /dev/tty has major==5 */ { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/null"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -159,7 +159,7 @@ static void test_policy_allow_list_major(const char *pattern, const char *cgroup } { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/full"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -172,7 +172,7 @@ static void test_policy_allow_list_major(const char *pattern, const char *cgroup } { - _cleanup_close_ int fd, fd2; + _cleanup_close_ int fd = -EBADF, fd2 = -EBADF; const char *s = "/dev/tty"; fd = open(s, O_CLOEXEC|O_RDONLY|O_NOCTTY); @@ -204,7 +204,7 @@ static void test_policy_allow_list_major_star(char type, const char *cgroup_path assert_se(r >= 0); { - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; const char *s = "/dev/null"; fd = open(s, O_CLOEXEC|O_RDWR|O_NOCTTY); @@ -237,7 +237,7 @@ static void test_policy_empty(bool add_mismatched, const char *cgroup_path, BPFP assert_se(r >= 0); { - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; const char *s = "/dev/null"; fd = open(s, O_CLOEXEC|O_RDWR|O_NOCTTY); diff --git a/src/test/test-compress-benchmark.c b/src/test/test-compress-benchmark.c index 6180e19839f..1727db8134d 100644 --- a/src/test/test-compress-benchmark.c +++ b/src/test/test-compress-benchmark.c @@ -78,7 +78,7 @@ static void test_compress_decompress(const char* label, const char* type, usec_t n, n2 = 0; float dt; - _cleanup_free_ char *text, *buf; + _cleanup_free_ char *text = NULL, *buf = NULL; _cleanup_free_ void *buf2 = NULL; size_t skipped = 0, compressed = 0, total = 0; diff --git a/src/test/test-copy.c b/src/test/test-copy.c index 38855fd45e0..f5bcb8756f9 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -144,7 +144,7 @@ TEST(copy_tree) { (void) rm_rf(original_dir, REMOVE_ROOT|REMOVE_PHYSICAL); STRV_FOREACH(p, files) { - _cleanup_free_ char *f, *c; + _cleanup_free_ char *f = NULL, *c = NULL; int k; assert_se(f = path_join(original_dir, *p)); @@ -159,7 +159,7 @@ TEST(copy_tree) { } STRV_FOREACH_PAIR(ll, p, symlinks) { - _cleanup_free_ char *f, *l; + _cleanup_free_ char *f = NULL, *l = NULL; assert_se(f = path_join(original_dir, *p)); assert_se(l = path_join(original_dir, *ll)); @@ -169,7 +169,7 @@ TEST(copy_tree) { } STRV_FOREACH_PAIR(ll, p, hardlinks) { - _cleanup_free_ char *f, *l; + _cleanup_free_ char *f = NULL, *l = NULL; assert_se(f = path_join(original_dir, *p)); assert_se(l = path_join(original_dir, *ll)); @@ -191,7 +191,7 @@ TEST(copy_tree) { assert_se(copy_tree(original_dir, copy_dir, UID_INVALID, GID_INVALID, COPY_REFLINK|COPY_MERGE|COPY_HARDLINKS, denylist) == 0); STRV_FOREACH(p, files) { - _cleanup_free_ char *buf, *f, *c = NULL; + _cleanup_free_ char *buf = NULL, *f = NULL, *c = NULL; size_t sz; int k; @@ -213,7 +213,7 @@ TEST(copy_tree) { } STRV_FOREACH_PAIR(ll, p, symlinks) { - _cleanup_free_ char *target, *f, *l; + _cleanup_free_ char *target = NULL, *f = NULL, *l = NULL; assert_se(f = strjoin(original_dir, *p)); assert_se(l = strjoin(copy_dir, *ll)); @@ -223,7 +223,7 @@ TEST(copy_tree) { } STRV_FOREACH_PAIR(ll, p, hardlinks) { - _cleanup_free_ char *f, *l; + _cleanup_free_ char *f = NULL, *l = NULL; struct stat a, b; assert_se(f = strjoin(copy_dir, *p)); diff --git a/src/test/test-date.c b/src/test/test-date.c index 16c6d4e5be2..a7058a33d42 100644 --- a/src/test/test-date.c +++ b/src/test/test-date.c @@ -46,7 +46,7 @@ static void test_should_fail(const char *p) { } static void test_one(const char *p) { - _cleanup_free_ char *with_utc; + _cleanup_free_ char *with_utc = NULL; with_utc = strjoin(p, " UTC"); test_should_pass(p); @@ -54,7 +54,7 @@ static void test_one(const char *p) { } static void test_one_noutc(const char *p) { - _cleanup_free_ char *with_utc; + _cleanup_free_ char *with_utc = NULL; with_utc = strjoin(p, " UTC"); test_should_pass(p); diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c index 2b27b44efb1..a96644f6176 100644 --- a/src/test/test-ellipsize.c +++ b/src/test/test-ellipsize.c @@ -75,7 +75,7 @@ TEST(ellipsize_mem) { } static void test_ellipsize_one(const char *p) { - _cleanup_free_ char *t; + _cleanup_free_ char *t = NULL; t = ellipsize(p, columns(), 70); puts(t); free(t); diff --git a/src/test/test-escape.c b/src/test/test-escape.c index f3dd579e56d..f74f4f590d1 100644 --- a/src/test/test-escape.c +++ b/src/test/test-escape.c @@ -6,14 +6,14 @@ #include "tests.h" TEST(cescape) { - _cleanup_free_ char *t; + _cleanup_free_ char *t = NULL; assert_se(t = cescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313")); assert_se(streq(t, "abc\\\\\\\"\\b\\f\\n\\r\\t\\v\\a\\003\\177\\234\\313")); } TEST(xescape) { - _cleanup_free_ char *t; + _cleanup_free_ char *t = NULL; assert_se(t = xescape("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", "")); assert_se(streq(t, "abc\\x5c\"\\x08\\x0c\\x0a\\x0d\\x09\\x0b\\x07\\x03\\x7f\\x9c\\xcb")); @@ -29,7 +29,7 @@ static void test_xescape_full_one(bool eight_bits) { log_info("/* %s */", __func__); for (unsigned i = 0; i < 60; i++) { - _cleanup_free_ char *t, *q; + _cleanup_free_ char *t = NULL, *q = NULL; assert_se(t = xescape_full("abc\\\"\b\f\n\r\t\v\a\003\177\234\313", "b", i, flags)); @@ -65,7 +65,7 @@ TEST(test_xescape_full) { } TEST(cunescape) { - _cleanup_free_ char *unescaped; + _cleanup_free_ char *unescaped = NULL; assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", 0, &unescaped) < 0); assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", UNESCAPE_RELAX, &unescaped) >= 0); @@ -132,7 +132,7 @@ TEST(cunescape) { } static void test_shell_escape_one(const char *s, const char *bad, const char *expected) { - _cleanup_free_ char *r; + _cleanup_free_ char *r = NULL; assert_se(r = shell_escape(s, bad)); log_debug("%s → %s (expected %s)", s, r, expected); @@ -203,7 +203,7 @@ TEST(shell_maybe_quote) { } static void test_quote_command_line_one(char **argv, const char *expected) { - _cleanup_free_ char *s; + _cleanup_free_ char *s = NULL; assert_se(s = quote_command_line(argv, SHELL_ESCAPE_EMPTY)); log_info("%s", s); @@ -224,7 +224,7 @@ TEST(quote_command_line) { } static void test_octescape_one(const char *s, const char *expected) { - _cleanup_free_ char *ret; + _cleanup_free_ char *ret = NULL; assert_se(ret = octescape(s, strlen_ptr(s))); log_debug("octescape(\"%s\") → \"%s\" (expected: \"%s\")", strnull(s), ret, expected); diff --git a/src/test/test-execve.c b/src/test/test-execve.c index 38adc728adf..e7a9a513774 100644 --- a/src/test/test-execve.c +++ b/src/test/test-execve.c @@ -20,7 +20,7 @@ */ static int run(int argc, char **argv) { - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; char **args = strv_skip(argv, 1); int r; diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index a570941cf30..aa5142fcedf 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -460,7 +460,7 @@ TEST(write_string_stream) { TEST(write_string_file) { _cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-write_string_file-XXXXXX"; char buf[64] = {}; - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; fd = mkostemp_safe(fn); assert_se(fd >= 0); @@ -473,7 +473,7 @@ TEST(write_string_file) { TEST(write_string_file_no_create) { _cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-write_string_file_no_create-XXXXXX"; - _cleanup_close_ int fd; + _cleanup_close_ int fd = -EBADF; char buf[64] = {}; fd = mkostemp_safe(fn); diff --git a/src/test/test-json.c b/src/test/test-json.c index 0f5c5b1a6e8..6a544c3fb7b 100644 --- a/src/test/test-json.c +++ b/src/test/test-json.c @@ -18,7 +18,7 @@ static void test_tokenizer_one(const char *data, ...) { void *state = NULL; va_list ap; - _cleanup_free_ char *cdata; + _cleanup_free_ char *cdata = NULL; assert_se(cdata = cescape(data)); log_info("/* %s data=\"%s\" */", __func__, cdata); diff --git a/src/test/test-nss-hosts.c b/src/test/test-nss-hosts.c index 2fbcde41d6b..7758f0adc98 100644 --- a/src/test/test-nss-hosts.c +++ b/src/test/test-nss-hosts.c @@ -449,7 +449,7 @@ static int parse_argv(int argc, char **argv, } } } else { - _cleanup_free_ char *hostname; + _cleanup_free_ char *hostname = NULL; assert_se(hostname = gethostname_malloc()); assert_se(names = strv_new("localhost", "_gateway", "_outbound", "foo_no_such_host", hostname)); diff --git a/src/test/test-sleep.c b/src/test/test-sleep.c index 55890760057..a873e6eb1bc 100644 --- a/src/test/test-sleep.c +++ b/src/test/test-sleep.c @@ -21,7 +21,7 @@ TEST(parse_sleep_config) { assert_se(parse_sleep_config(&sleep_config) == 0); - _cleanup_free_ char *sum, *sus, *him, *his, *hym, *hys; + _cleanup_free_ char *sum = NULL, *sus = NULL, *him = NULL, *his = NULL, *hym = NULL, *hys = NULL; sum = strv_join(sleep_config->modes[SLEEP_SUSPEND], ", "); sus = strv_join(sleep_config->states[SLEEP_SUSPEND], ", "); diff --git a/src/test/test-strbuf.c b/src/test/test-strbuf.c index f69e80ca5a8..39a7142b5bb 100644 --- a/src/test/test-strbuf.c +++ b/src/test/test-strbuf.c @@ -13,8 +13,8 @@ static ssize_t add_string(struct strbuf *sb, const char *s) { } TEST(strbuf) { - _cleanup_(strbuf_freep) struct strbuf *sb; - _cleanup_strv_free_ char **l; + _cleanup_(strbuf_freep) struct strbuf *sb = NULL; + _cleanup_strv_free_ char **l = NULL; ssize_t a, b, c, d, e, f, g, h; sb = strbuf_new(); diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index 65052c627d7..2d3e40321e5 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -259,7 +259,7 @@ TEST(strextend_with_separator) { } TEST(strrep) { - _cleanup_free_ char *one, *three, *zero; + _cleanup_free_ char *one = NULL, *three = NULL, *zero = NULL; one = strrep("waldo", 1); three = strrep("waldo", 3); zero = strrep("waldo", 0); diff --git a/src/test/test-strv.c b/src/test/test-strv.c index a39a2d81220..5feafc95e01 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -200,8 +200,8 @@ TEST(strv_join_full) { } static void test_strv_unquote_one(const char *quoted, char **list) { - _cleanup_strv_free_ char **s; - _cleanup_free_ char *j; + _cleanup_strv_free_ char **s = NULL; + _cleanup_free_ char *j = NULL; unsigned i = 0; int r; diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c index 42701618048..e80922901e0 100644 --- a/src/test/test-time-util.c +++ b/src/test/test-time-util.c @@ -244,7 +244,7 @@ TEST(format_timespan) { test_format_timespan_accuracy(USEC_PER_SEC); /* See issue #23928. */ - _cleanup_free_ char *buf; + _cleanup_free_ char *buf = NULL; assert_se(buf = new(char, 5)); assert_se(buf == format_timespan(buf, 5, 100005, 1000)); } diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index ed3f2dfc786..ada8330408c 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -583,7 +583,7 @@ TEST(unit_name_to_instance) { } TEST(unit_name_escape) { - _cleanup_free_ char *r; + _cleanup_free_ char *r = NULL; r = unit_name_escape("ab+-c.a/bc@foo.service"); assert_se(r); diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c index 7ba0cb7dd23..1b7da9d511e 100644 --- a/src/test/test-utf8.c +++ b/src/test/test-utf8.c @@ -99,7 +99,7 @@ TEST(utf8_encoded_valid_unichar) { } TEST(utf8_escape_invalid) { - _cleanup_free_ char *p1, *p2, *p3; + _cleanup_free_ char *p1 = NULL, *p2 = NULL, *p3 = NULL; p1 = utf8_escape_invalid("goo goo goo"); log_debug("\"%s\"", p1); @@ -115,7 +115,7 @@ TEST(utf8_escape_invalid) { } TEST(utf8_escape_non_printable) { - _cleanup_free_ char *p1, *p2, *p3, *p4, *p5, *p6; + _cleanup_free_ char *p1 = NULL, *p2 = NULL, *p3 = NULL, *p4 = NULL, *p5 = NULL, *p6 = NULL; p1 = utf8_escape_non_printable("goo goo goo"); log_debug("\"%s\"", p1); @@ -148,7 +148,7 @@ TEST(utf8_escape_non_printable_full) { "\001 \019\20\a", /* control characters */ "\xef\xbf\x30\x13") /* misplaced continuation bytes followed by a digit and cc */ for (size_t cw = 0; cw < 22; cw++) { - _cleanup_free_ char *p, *q; + _cleanup_free_ char *p = NULL, *q = NULL; size_t ew; p = utf8_escape_non_printable_full(s, cw, false); diff --git a/src/xdg-autostart-generator/test-xdg-autostart.c b/src/xdg-autostart-generator/test-xdg-autostart.c index e11f3d9385d..81f85d6b156 100644 --- a/src/xdg-autostart-generator/test-xdg-autostart.c +++ b/src/xdg-autostart-generator/test-xdg-autostart.c @@ -10,7 +10,7 @@ #include "xdg-autostart-service.h" TEST(translate_name) { - _cleanup_free_ char *t; + _cleanup_free_ char *t = NULL; assert_se(t = xdg_autostart_service_translate_name("a-b.blub.desktop")); assert_se(streq(t, "app-a\\x2db.blub@autostart.service")); @@ -26,7 +26,7 @@ static void test_xdg_format_exec_start_one(const char *exec, const char *expecte TEST(xdg_format_exec_start) { _cleanup_free_ char *home = NULL; - _cleanup_free_ char *expected1, *expected2 = NULL; + _cleanup_free_ char *expected1 = NULL, *expected2 = NULL; assert_se(get_home_dir(&home) >= 0);