]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
various: fix 'uninitialized when used' warnings [clang]
authorSami Kerola <kerolasa@iki.fi>
Sat, 9 Feb 2019 09:34:52 +0000 (09:34 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2019 12:19:24 +0000 (13:19 +0100)
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
15 files changed:
disk-utils/mkfs.minix.c
disk-utils/sfdisk.c
libblkid/src/partitions/dos.c
libblkid/src/partitions/partitions.c
libblkid/src/superblocks/ddf_raid.c
libblkid/src/superblocks/hfs.c
libblkid/src/superblocks/zfs.c
libfdisk/src/dos.c
libfdisk/src/table.c
misc-utils/logger.c
misc-utils/uuidd.c
misc-utils/uuidparse.c
sys-utils/hwclock.c
sys-utils/readprofile.c
sys-utils/setarch.c

index 54c47da7e5a3aa8dfdf3b9028655b34eb1cd7def..8e6811f49d956f9b29d9ccbf5e8f1bcaa165e37d 100644 (file)
@@ -685,7 +685,7 @@ static int find_super_magic(const struct fs_control *ctl)
 
 static void determine_device_blocks(struct fs_control *ctl, const struct stat *statbuf)
 {
-       unsigned long long dev_blocks;
+       unsigned long long dev_blocks = 0;
 
        if (S_ISBLK(statbuf->st_mode)) {
                int sectorsize;
index 52ccc5251cfee59258c1fe8cc03cb792bc1c59e4..2427cef5b3430f75640fdc24320de20c3fc281db 100644 (file)
@@ -1724,7 +1724,7 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
 
                nparts = fdisk_table_get_nents(tb);
                if (nparts) {
-                       size_t cur_partno;
+                       size_t cur_partno = (size_t) -1;
                        struct fdisk_partition *pa = fdisk_table_get_partition(tb, nparts - 1);
 
                        assert(pa);
index 659ca9a1669a83680dd5c0ca88f01fd796cf4a45..6c1b519f79c4ee13dc5ec1ceb4a26cc51f26ffe1 100644 (file)
@@ -55,7 +55,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
 
        while (1) {
                struct dos_partition *p, *p0;
-               uint32_t start, size;
+               uint32_t start = 0, size;
 
                if (++ct_nodata > 100)
                        return BLKID_PROBE_OK;
index b5f393b99c97e8bd798831ea922c793181cf2201..299454765ea0fdb624ad85443133edda40e839e6 100644 (file)
@@ -1010,7 +1010,7 @@ blkid_partition blkid_partlist_get_partition_by_partno(blkid_partlist ls, int n)
 blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno)
 {
        struct path_cxt *pc;
-       uint64_t start, size;
+       uint64_t start = 0, size;
        int i, rc, partno = 0;
 
        DBG(LOWPROBE, ul_debug("trying to convert devno 0x%llx to partition",
index fc2c39d3e597f4302f22c968f274b4e4c4dec1ca..0b82e73eb69ae4789ead8fd24efb00b8d2946623 100644 (file)
@@ -78,7 +78,7 @@ static int probe_ddf(blkid_probe pr,
        size_t i;
        struct ddf_header *ddf = NULL;
        char version[DDF_REV_LENGTH + 1];
-       uint64_t off, lba;
+       uint64_t off = 0, lba;
 
        if (pr->size < 0x30000)
                return 1;
index 7b0117405010ae367cc0c39c43d97b6e83788438..6f170a3cd6238612adb3f79ba9cb40a9ccf43022 100644 (file)
@@ -191,7 +191,7 @@ static int probe_hfsplus(blkid_probe pr, const struct blkid_idmag *mag)
        unsigned int off = 0;
        unsigned int blocksize;
        unsigned int cat_block;
-       unsigned int ext_block_start;
+       unsigned int ext_block_start = 0;
        unsigned int ext_block_count;
        unsigned int record_count;
        unsigned int leaf_node_head;
index 1292b303be8520cbba4341c70cd0ce7e79a1c729..4d4b46d5518867a23541368b24f56df1aab34ea6 100644 (file)
@@ -218,7 +218,7 @@ static int probe_zfs(blkid_probe pr,
        const struct blkid_idmag *mag  __attribute__((__unused__)))
 {
        int swab_endian = 0;
-       struct zfs_uberblock *ub;
+       struct zfs_uberblock *ub = NULL;
        loff_t offset = 0, ub_offset = 0;
        int label_no, found = 0, found_in_label;
        void *label;
index 2e46aca70be272f98365e40598cbaa4d9d71fe97..8e9678da3e1e979369894babb4239a9a9b279af3 100644 (file)
@@ -1708,7 +1708,7 @@ static int dos_add_partition(struct fdisk_context *cxt,
        } else {
                char hint[BUFSIZ];
                struct fdisk_ask *ask;
-               int c;
+               int c = 0;
 
                /* the default layout for scripts is to create primary partitions */
                if (cxt->script || !fdisk_has_dialogs(cxt)) {
index 99a669ca21fa07f17ade2042bfe123d885a1e127..1f9d5a28a573c5466af4c22365cf5d2f62f4925e 100644 (file)
@@ -728,7 +728,7 @@ int fdisk_diff_tables(struct fdisk_table *a, struct fdisk_table *b,
                      struct fdisk_iter *itr,
                      struct fdisk_partition **res, int *change)
 {
-       struct fdisk_partition *pa, *pb;
+       struct fdisk_partition *pa = NULL, *pb;
        int rc = 1;
 
        assert(itr);
index 10b307ef9fc47cb8349840ad4c78e52e654440a7..394a477db4d3fb7951cd4c14b5326f89bbde527f 100644 (file)
@@ -237,7 +237,7 @@ static int pencode(char *s)
 
 static int unix_socket(struct logger_ctl *ctl, const char *path, int *socket_type)
 {
-       int fd, i, type = -1;
+       int fd = -1, i, type = -1;
        static struct sockaddr_un s_addr;       /* AF_UNIX address of local logger */
 
        if (strlen(path) >= sizeof(s_addr.sun_path))
index e0be809dde31e00535ab4e509d3e7fe38cc6e6ca..0382bac47d0b9f001d7de44f7f5d94619a7fe308 100644 (file)
@@ -313,7 +313,8 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
        uuid_t                  uu;
        char                    reply_buf[1024], *cp;
        char                    op, str[UUID_STR_LEN];
-       int                     i, ns, len, num;
+       int                     i, ns, len;
+       int                     num;            /* intentionally uninitialized */
        int                     s = 0;
        int                     fd_pidfile = -1;
        int                     ret;
index 777f9db5e586c83b6232b8265fee16e74f269540..6a13f2a2b91bd2d648671488f9165e68e6f573d7 100644 (file)
@@ -144,7 +144,7 @@ static void fill_table_row(struct libscols_table *tb, char const *const uuid)
        size_t i;
        uuid_t buf;
        int invalid = 0;
-       int variant, type;
+       int variant = -1, type = -1;
 
        assert(tb);
        assert(uuid);
index d9acbaf7d8bcb7051396b0aecc1ab63eeacf0d87..5f4c014fc54d999c6c8cf6f23f212f640b6a0f24 100644 (file)
@@ -954,7 +954,7 @@ manipulate_clock(const struct hwclock_control *ctl, const time_t set_time,
                 const struct timeval startup_time, struct adjtime *adjtime)
 {
        /* The time at which we read the Hardware Clock */
-       struct timeval read_time;
+       struct timeval read_time = { 0 };
        /*
         * The Hardware Clock gives us a valid time, or at
         * least something close enough to fool mktime().
index 75a623bc98757ba739b89d139f89be484b2b1527..ca0037529c220df8d65553a83ffb94e4c3459392 100644 (file)
@@ -136,7 +136,7 @@ int main(int argc, char **argv)
        unsigned long long add0 = 0;
        unsigned int step;
        unsigned int *buf, total, fn_len;
-       unsigned long long fn_add, next_add;    /* current and next address */
+       unsigned long long fn_add = 0, next_add; /* current and next address */
        char fn_name[S_LEN], next_name[S_LEN];  /* current and next name */
        char mode[8];
        int c;
index 703c36d864e150f701cefeeb58b9e44e272208c7..31016f7f13631768a63992286c957b24f8c71896 100644 (file)
@@ -266,7 +266,7 @@ int main(int argc, char *argv[])
        int verbose = 0;
        int archwrapper;
        int c;
-       struct arch_domain *doms, *target;
+       struct arch_domain *doms, *target = NULL;
        unsigned long pers_value = 0;
        char *shell = NULL, *shell_arg = NULL;