chiark / gitweb /
make gcc shut up
authorLennart Poettering <lennart@poettering.net>
Wed, 19 Feb 2014 16:47:11 +0000 (17:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 19 Feb 2014 16:53:50 +0000 (17:53 +0100)
If -flto is used then gcc will generate a lot more warnings than before,
among them a number of use-without-initialization warnings. Most of them
without are false positives, but let's make them go away, because it
doesn't really matter.

30 files changed:
src/backlight/backlight.c
src/boot/boot-efi.c
src/cgtop/cgtop.c
src/core/dbus-manager.c
src/hostname/hostnamectl.c
src/journal/journal-gatewayd.c
src/journal/journalctl.c
src/journal/sd-journal.c
src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/test-bus-memfd.c
src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-event/test-event.c
src/login/logind-session.c
src/login/test-login.c
src/machine/machine.c
src/network/networkd-link.c
src/nspawn/nspawn.c
src/shared/acpi-fpdt.c
src/shared/boot-timestamps.c
src/shared/efivars.c
src/shared/sleep-config.c
src/shared/socket-util.c
src/shared/util.c
src/test/test-cgroup-mask.c
src/test/test-sched-prio.c
src/test/test-unit-name.c
src/test/test-util.c
src/tty-ask-password-agent/tty-ask-password-agent.c
src/udev/udev-ctrl.c

index 7d7c0845d91ba73217d5c10805b5139ee7347436..86f10cc0cf290f15dc5978a74e8a3b9d9f04add3 100644 (file)
@@ -64,7 +64,7 @@ static struct udev_device *find_pci_or_platform_parent(struct udev_device *devic
 
                 value = udev_device_get_sysattr_value(parent, "class");
                 if (value) {
-                        unsigned long class;
+                        unsigned long class = 0;
 
                         if (safe_atolu(value, &class) < 0) {
                                 log_warning("Cannot parse PCI class %s of device %s:%s.", value, subsystem, sysname);
index 426652595e4d45ede41707713753c317bca902ee..bd0c59bd5aef936d95507eff0b77c7d6acc31c47 100644 (file)
@@ -50,7 +50,7 @@ static char *tilt_slashes(char *s) {
 }
 
 static int get_boot_entries(struct boot_info *info) {
-        uint16_t *list;
+        uint16_t *list = NULL;
         int i, n;
         int err = 0;
 
index c56f7a861f51a48fca5c53eaf68454aa6f34f69b..fd0023b0a84ef7f57c7bb5d81a8040422627b91c 100644 (file)
@@ -98,7 +98,7 @@ static void group_hashmap_free(Hashmap *h) {
 static int process(const char *controller, const char *path, Hashmap *a, Hashmap *b, unsigned iteration) {
         Group *g;
         int r;
-        FILE *f;
+        FILE *f = NULL;
         pid_t pid;
         unsigned n;
 
index 6abd5993706726f84c91d804c75c99fda212d08f..a9b8fad25c0f0f50880d8140acfaa04c8855e75a 100644 (file)
@@ -873,7 +873,7 @@ static int method_create_snapshot(sd_bus *bus, sd_bus_message *message, void *us
         Manager *m = userdata;
         const char *name;
         int cleanup;
-        Snapshot *s;
+        Snapshot *s = NULL;
         int r;
 
         assert(bus);
index 3150396c70e89d2167e94616f4953d7694cea43f..afbf37db517561c32124f690b5548c43dbd99c80 100644 (file)
@@ -69,7 +69,7 @@ typedef struct StatusInfo {
 } StatusInfo;
 
 static void print_status_info(StatusInfo *i) {
-        sd_id128_t mid, bid;
+        sd_id128_t mid = {}, bid = {};
         int r;
         const char *id = NULL;
         _cleanup_free_ char *pretty_name = NULL, *cpe_name = NULL;
index 5c35d8e77ec8a332f76acb83e872970c9010bb23..7e97a3588ce09abbd18befd4f094b05a6bec887e 100644 (file)
@@ -744,7 +744,7 @@ static int request_handler_file(
 
 static int get_virtualization(char **v) {
         _cleanup_bus_unref_ sd_bus *bus = NULL;
-        char *b;
+        char *b = NULL;
         int r;
 
         r = sd_bus_default_system(&bus);
@@ -780,7 +780,7 @@ static int request_handler_machine(
         RequestMeta *m = connection_cls;
         int r;
         _cleanup_free_ char* hostname = NULL, *os_name = NULL;
-        uint64_t cutoff_from, cutoff_to, usage;
+        uint64_t cutoff_from = 0, cutoff_to = 0, usage;
         char *json;
         sd_id128_t mid, bid;
         _cleanup_free_ char *v = NULL;
index d406daeae99d6fecca6d3c942d108e424e9da213..a328ba11b0d3193daae39d1e18be28fb309ffd57 100644 (file)
@@ -1651,7 +1651,7 @@ int main(int argc, char *argv[]) {
         }
 
         if (arg_action == ACTION_DISK_USAGE) {
-                uint64_t bytes;
+                uint64_t bytes = 0;
                 char sbytes[FORMAT_BYTES_MAX];
 
                 r = sd_journal_get_usage(j, &bytes);
index 6abbacf004f0b58a52065705c25e53acd001003f..fa2009c5dc5c256e161988664ef27f7f962d0865 100644 (file)
@@ -1281,7 +1281,7 @@ static bool file_type_wanted(int flags, const char *filename) {
 }
 
 static int add_any_file(sd_journal *j, const char *path) {
-        JournalFile *f;
+        JournalFile *f = NULL;
         int r;
 
         assert(j);
index 846307d6647d1f23d94804efba66b5f067103d96..b4dbb5b7eeb2ab915b4a0e621d00245b17a4772e 100644 (file)
@@ -687,8 +687,8 @@ static int bus_get_owner_dbus1(
                 }
 
                 if (mask & SD_BUS_CREDS_SELINUX_CONTEXT) {
-                        const void *p;
-                        size_t sz;
+                        const void *p = NULL;
+                        size_t sz = 0;
 
                         r = sd_bus_call_method(
                                         bus,
index 323413406a4e278d062d99d678feb5155e54aeda..fe84f3f0bcc8284f802486a953681411b6de95e7 100644 (file)
@@ -1863,7 +1863,7 @@ _public_ int sd_bus_message_open_container(
         struct bus_container *c, *w;
         uint32_t *array_size = NULL;
         char *signature;
-        size_t before, begin;
+        size_t before, begin = 0;
         bool need_offsets = false;
         int r;
 
index f7197ed096d697ebf42c49f8192d7cc3cd61d0f2..f0f08ba818703876d65f84422f0df76013f84401 100644 (file)
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
         char *s, *name;
         uint64_t sz;
         int r, fd;
-        FILE *f;
+        FILE *f = NULL;
         char buf[3] = {};
         struct iovec iov[3] = {};
         char bufv[3][3] = {};
index cf2efa68a35c9c4bc21dc9a387177ad20e40720e..cda92e260454c4f6575ca3786f079f55fa4ab000 100644 (file)
@@ -642,9 +642,9 @@ static int event_setup_timer_fd(
                 int *timer_fd,
                 clockid_t id) {
 
+        sd_id128_t bootid = {};
         struct epoll_event ev = {};
         int r, fd;
-        sd_id128_t bootid;
 
         assert(e);
         assert(timer_fd);
@@ -2126,7 +2126,7 @@ _public_ int sd_event_get_now_monotonic(sd_event *e, uint64_t *usec) {
 _public_ int sd_event_default(sd_event **ret) {
 
         static thread_local sd_event *default_event = NULL;
-        sd_event *e;
+        sd_event *e = NULL;
         int r;
 
         if (!ret)
index 28ef6a3692bf2bb0657b51c6dadd454b54afbef2..c10aa8caa76a938a4418bdb0bce9b1a11d598bd6 100644 (file)
@@ -76,7 +76,7 @@ static int child_handler(sd_event_source *s, const siginfo_t *si, void *userdata
 }
 
 static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
-        sd_event_source *p;
+        sd_event_source *p = NULL;
         sigset_t ss;
         pid_t pid;
 
@@ -106,7 +106,7 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
 }
 
 static int defer_handler(sd_event_source *s, void *userdata) {
-        sd_event_source *p;
+        sd_event_source *p = NULL;
         sigset_t ss;
 
         assert(s);
index d7c074bdce8b4022bcbdf1675793b57fd944ff20..dc1d81c4be94271bc1451815709634fd87cb3628 100644 (file)
@@ -480,7 +480,7 @@ static int session_start_scope(Session *s) {
         if (!s->scope) {
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
                 _cleanup_free_ char *description = NULL;
-                char *scope, *job;
+                char *scope, *job = NULL;
 
                 description = strjoin("Session ", s->id, " of user ", s->user->name, NULL);
                 if (!description)
@@ -567,7 +567,7 @@ int session_start(Session *s) {
 
 static int session_stop_scope(Session *s, bool force) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        char *job;
+        char *job = NULL;
         int r;
 
         assert(s);
index ce88af80f06f1b79b9d7448346b7780fd7adb452..d78cea46af9a8a5efd0090025070b71a8957086b 100644 (file)
@@ -39,7 +39,7 @@ static void test_login(void) {
         uid_t *uids;
         unsigned n;
         struct pollfd pollfd;
-        sd_login_monitor *m;
+        sd_login_monitor *m = NULL;
 
         assert_se(sd_pid_get_session(0, &session) == 0);
         printf("session = %s\n", session);
index e45c443495c0650f5372d927a2c2f29b44298f47..4596a80838f6bd8f751110715f45c9e66696910c 100644 (file)
@@ -252,7 +252,7 @@ static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_er
 
         if (!m->unit) {
                 _cleanup_free_ char *escaped = NULL;
-                char *scope, *description, *job;
+                char *scope, *description, *job = NULL;
 
                 escaped = unit_name_escape(m->name);
                 if (!escaped)
@@ -322,7 +322,7 @@ int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) {
 
 static int machine_stop_scope(Machine *m) {
         _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        char *job;
+        char *job = NULL;
         int r;
 
         assert(m);
index 37bc5ab594eca1324be6e0c7747e6769390fbf97..e574b2c874be9a6b48e3b7c1ea0c57870eca1afa 100644 (file)
@@ -105,7 +105,7 @@ int link_get(Manager *m, int ifindex, Link **ret) {
 }
 
 int link_add(Manager *m, struct udev_device *device, Link **ret) {
-        Link *link;
+        Link *link = NULL;
         Network *network;
         int r;
 
index 350dc93cf9f873dd934e6a4b4ae6350dc4363873..62c2e2ef0928823844d30040556e6b4f69265bd5 100644 (file)
@@ -743,7 +743,7 @@ static int setup_resolv_conf(const char *dest) {
 
 static int setup_boot_id(const char *dest) {
         _cleanup_free_ char *from = NULL, *to = NULL;
-        sd_id128_t rnd;
+        sd_id128_t rnd = {};
         char as_uuid[37];
         int r;
 
index 7bae47f85f2fb5199e301233f092a984a002798c..390c3236e097ce8bba1e4ee2a3e4f56d66414bf7 100644 (file)
@@ -83,7 +83,7 @@ struct acpi_fpdt_boot {
 int acpi_get_boot_usec(usec_t *loader_start, usec_t *loader_exit) {
         _cleanup_free_ char *buf = NULL;
         struct acpi_table_header *tbl;
-        size_t l;
+        size_t l = 0;
         struct acpi_fpdt_header *rec;
         int r;
         uint64_t ptr = 0;
index d656685774b78e679cb94d978842d383bdf2c7c8..54e0537a212b999f6ecee922aa863b080d31a38a 100644 (file)
@@ -26,7 +26,7 @@
 #include "efivars.h"
 
 int boot_timestamps(const dual_timestamp *n, dual_timestamp *firmware, dual_timestamp *loader) {
-        usec_t x, y, a;
+        usec_t x = 0, y = 0, a;
         int r;
         dual_timestamp _n;
 
index 000dae9de0fd0f389823d7339ea638b8165c45f6..5ee8f1eb0b0fb475a339a25e0a60c81d4c28713d 100644 (file)
@@ -130,7 +130,7 @@ int efi_get_variable(
 
 int efi_get_variable_string(sd_id128_t vendor, const char *name, char **p) {
         _cleanup_free_ void *s = NULL;
-        size_t ss;
+        size_t ss = 0;
         int r;
         char *x;
 
@@ -393,7 +393,7 @@ fail:
 static int read_usec(sd_id128_t vendor, const char *name, usec_t *u) {
         _cleanup_free_ char *j = NULL;
         int r;
-        uint64_t x;
+        uint64_t x = 0;
 
         assert(name);
         assert(u);
index b9b6643066cc86773e83dbf2a5fde702f6ae4c10..cf1cd400e8fb281d0cb3149f8dc17f3154649333 100644 (file)
@@ -220,8 +220,8 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
 
 static bool enough_memory_for_hibernation(void) {
         _cleanup_free_ char *active = NULL;
-        unsigned long long act;
-        size_t size, used;
+        unsigned long long act = 0;
+        size_t size = 0, used = 0;
         int r;
 
         r = hibernation_partition_size(&size, &used);
index 6d9c30352964644e85eb5bc0e66c8cb22923ae47..5ef2e2244c0406874fd8b7cbdd067a610c853fb2 100644 (file)
@@ -585,7 +585,7 @@ int getpeername_pretty(int fd, char **ret) {
                 return -errno;
 
         if (sa.sa.sa_family == AF_UNIX) {
-                struct ucred ucred;
+                struct ucred ucred = {};
 
                 /* UNIX connection sockets are anonymous, so let's use
                  * PID/UID as pretty credentials instead */
index 55246f5a4d769eeb98206a29deafb80affe24b9b..35e4338c3a810a8d5b4d13440587aff9e1e80ff0 100644 (file)
@@ -5903,7 +5903,7 @@ int proc_cmdline(char **ret) {
         int r;
 
         if (detect_container(NULL) > 0) {
-                char *buf, *p;
+                char *buf = NULL, *p;
                 size_t sz = 0;
 
                 r = read_full_file("/proc/1/cmdline", &buf, &sz);
index 3414ed4d605a59ef9b50342ee3ae776e29c20b46..4d60859513b774a660bcd83d35ab66ee9275d100 100644 (file)
@@ -32,7 +32,7 @@
 #include "test-helper.h"
 
 static int test_cgroup_mask(void) {
-        Manager *m;
+        Manager *m = NULL;
         Unit *son, *daughter, *parent, *root, *grandchild, *parent_deep;
         FILE *serial = NULL;
         FDSet *fdset = NULL;
index a4cc3d44a288ed94c0839bd6970e4bcc8088fb99..e984ee420375478b828d075d00e1156301511d71 100644 (file)
@@ -25,7 +25,7 @@
 #include "macro.h"
 
 int main(int argc, char *argv[]) {
-        Manager *m;
+        Manager *m = NULL;
         Unit *idle_ok, *idle_bad, *rr_ok, *rr_bad, *rr_sched;
         Service *ser;
         FILE *serial = NULL;
index c10ec608af5e60801d08e5a2581a15f77d93e83e..fff3e16ed816b82344433112c8dd534139ac8e0c 100644 (file)
@@ -110,7 +110,7 @@ static void test_replacements(void) {
 }
 
 static int test_unit_printf(void) {
-        Manager *m;
+        Manager *m = NULL;
         Unit *u, *u2;
         int r;
 
index cbd60d68f7ff2a01533b5fec18a072f16fbb53ad..1ac4a1edd1192127106acdfd29a32905f1fcc69b 100644 (file)
@@ -567,11 +567,11 @@ static void test_in_set(void) {
 
 static void test_writing_tmpfile(void) {
         char name[] = "/tmp/test-systemd_writing_tmpfile.XXXXXX";
-        _cleanup_free_ char *contents;
+        _cleanup_free_ char *contents = NULL;
         size_t size;
         int fd, r;
-
         struct iovec iov[3];
+
         IOVEC_SET_STRING(iov[0], "abc\n");
         IOVEC_SET_STRING(iov[1], ALPHANUMERICAL "\n");
         IOVEC_SET_STRING(iov[2], "");
index 08177c6d04f080bb02e76cfe966183fe118b55ea..7a90e6507fb1b59b9f18e2232af39c601b81abb8 100644 (file)
@@ -361,7 +361,7 @@ static int parse_password(const char *filename, char **wall) {
 
                 } else {
                         int tty_fd = -1;
-                        char *password;
+                        char *password = NULL;
 
                         if (arg_console)
                                 if ((tty_fd = acquire_terminal("/dev/console", false, false, false, (usec_t) -1)) < 0) {
index 263342335260f3d00ffec159e24d01e501c844b5..1e91ec20a1f8930460a91016daa22d8be8bcbada 100644 (file)
@@ -180,7 +180,7 @@ int udev_ctrl_get_fd(struct udev_ctrl *uctrl)
 struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl)
 {
         struct udev_ctrl_connection *conn;
-        struct ucred ucred;
+        struct ucred ucred = {};
         const int on = 1;
         int r;