]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc: fix compiler warnungs (unsigned/signed)
authorRuediger Meier <ruediger.meier@ga-group.nl>
Mon, 22 Feb 2016 23:54:41 +0000 (00:54 +0100)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 23 Feb 2016 02:18:27 +0000 (03:18 +0100)
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
15 files changed:
disk-utils/partx.c
libblkid/src/partitions/partitions.c
libblkid/src/probe.c
libblkid/src/superblocks/linux_raid.c
libblkid/src/superblocks/superblocks.c
libblkid/src/superblocks/xfs.c
libfdisk/src/ask.c
libfdisk/src/context.c
libfdisk/src/dos.c
libfdisk/src/gpt.c
libfdisk/src/script.c
libfdisk/src/utils.c
libsmartcols/src/table.c
libsmartcols/src/table_print.c
misc-utils/logger.c

index ffc74d6987991043a48f21b55295f164333f2fb3..f01cf22c500d323706e0d6a941686a2587c0b4a3 100644 (file)
@@ -137,7 +137,7 @@ static void assoc_loopdev(const char *fname)
 static inline int get_column_id(int num)
 {
        assert(ARRAY_SIZE(columns) == NCOLS);
-       assert(num < ncolumns);
+       assert((size_t)num < ncolumns);
        assert(columns[num] < (int) NCOLS);
        return columns[num];
 }
@@ -548,7 +548,7 @@ static int add_scols_line(struct libscols_table *table, blkid_partition par)
                return -ENOMEM;
        }
 
-       for (i = 0; i < ncolumns; i++) {
+       for (i = 0; (size_t)i < ncolumns; i++) {
                char *str = NULL;                       /* allocated string */
                const char *cstr = NULL;                /* foreign string */
 
@@ -637,7 +637,7 @@ static int show_parts(blkid_partlist ls, int scols_flags, int lower, int upper)
        scols_table_enable_export(table, !!(scols_flags & PARTX_EXPORT));
        scols_table_enable_noheadings(table, !!(scols_flags & PARTX_NOHEADINGS));
 
-       for (i = 0; i < ncolumns; i++) {
+       for (i = 0; (size_t)i < ncolumns; i++) {
                struct colinfo *col = get_column_info(i);
 
                if (!scols_table_new_column(table, col->name, col->whint, col->flags)) {
index 7c37dfb96f7748d45697eecde6514ea2fc9ff598..c8e0bfeb071415c606c3d9f0d2232197c7e1a5ad 100644 (file)
@@ -537,7 +537,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id,
        uint64_t off;
        int rc = BLKID_PROBE_NONE;              /* default is nothing */
 
-       if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
+       if (pr->size <= 0 || (id->minsz && (unsigned)id->minsz > pr->size))
                goto nothing;   /* the device is too small */
        if (pr->flags & BLKID_FL_NOSCAN_DEV)
                goto nothing;
@@ -1040,7 +1040,7 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
                         if (partno != blkid_partition_get_partno(par))
                                 continue;
 
-                        if (size == blkid_partition_get_size(par) ||
+                        if (size == (uint64_t)blkid_partition_get_size(par) ||
                             (blkid_partition_is_extended(par) && size <= 1024ULL))
                                 return par;
 
@@ -1053,12 +1053,12 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
        for (i = 0; i < ls->nparts; i++) {
                blkid_partition par = &ls->parts[i];
 
-               if (blkid_partition_get_start(par) == start &&
-                   blkid_partition_get_size(par) == size)
+               if ((uint64_t)blkid_partition_get_start(par) == start &&
+                   (uint64_t)blkid_partition_get_size(par) == size)
                        return par;
 
                /* exception for extended dos partitions */
-               if (blkid_partition_get_start(par) == start &&
+               if ((uint64_t)blkid_partition_get_start(par) == start &&
                    blkid_partition_is_extended(par) && size <= 1024ULL)
                        return par;
 
@@ -1196,7 +1196,7 @@ blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
  */
 blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
 {
-       return tab ? tab->offset : -1;
+       return tab ? (blkid_loff_t)tab->offset : -1;
 }
 
 /**
@@ -1407,7 +1407,7 @@ int blkid_partition_get_partno(blkid_partition par)
  */
 blkid_loff_t blkid_partition_get_start(blkid_partition par)
 {
-       return par ? par->start : -1;
+       return par ? (blkid_loff_t)par->start : -1;
 }
 
 /**
@@ -1428,7 +1428,7 @@ blkid_loff_t blkid_partition_get_start(blkid_partition par)
  */
 blkid_loff_t blkid_partition_get_size(blkid_partition par)
 {
-       return par ? par->size : -1;
+       return par ? (blkid_loff_t)par->size : -1;
 }
 
 /**
index 5f15b09813c77a00a26936f9d4aaa321264e61d9..cc4586bf21edff6bb9365c248056a690683e9491 100644 (file)
@@ -390,7 +390,7 @@ static const char *blkid_probe_get_probername(blkid_probe pr)
 {
        struct blkid_chain *chn = blkid_probe_get_chain(pr);
 
-       if (chn && chn->idx >= 0 && chn->idx < chn->driver->nidinfos)
+       if (chn && chn->idx >= 0 && (unsigned)chn->idx < chn->driver->nidinfos)
                return chn->driver->idinfos[chn->idx]->name;
 
        return NULL;
@@ -904,7 +904,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
        else if (S_ISREG(sb.st_mode))
                devsiz = sb.st_size;    /* regular file */
 
-       pr->size = size ? size : devsiz;
+       pr->size = size ? (uint64_t)size : devsiz;
 
        if (off && size == 0)
                /* only offset without size specified */
@@ -1218,7 +1218,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
            offset, offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
 
        l = blkid_llseek(fd, offset, SEEK_SET);
-       if (l == (off_t) -1)
+       if ((blkid_loff_t)l == (off_t) -1)
                return -1;
 
        memset(buf, 0, len);
index e60c5e597b8d19c8b65676149db01d17a5e3bc6a..e6b496a35f53dd35a5d33fe3b5365d817b5c0506 100644 (file)
@@ -148,11 +148,11 @@ static int probe_raid0(blkid_probe pr, uint64_t off)
 
        size <<= 10;    /* convert KiB to bytes */
 
-       if (pr->size < 0 || (uint64_t) pr->size < size + MD_RESERVED_BYTES)
+       if (pr->size < size + MD_RESERVED_BYTES)
                /* device is too small */
                return 1;
 
-       if (off < 0 || (uint64_t) off < size)
+       if (off < size)
                /* no space before superblock */
                return 1;
 
index 2b850305daec1c6acae9cd7666d7d31913ee6189..987a647d56dad8bb49586f1f75af9b4931920461 100644 (file)
@@ -372,7 +372,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
                        continue;
                }
 
-               if (id->minsz && id->minsz > pr->size) {
+               if (id->minsz && (unsigned)id->minsz > pr->size) {
                        rc = BLKID_PROBE_NONE;
                        continue;       /* the device is too small */
                }
index 575651b22c73d553c166f95f4389f7bab1866cc9..01e9cda8200c3349b6f4b2e168d138d57561d4fe 100644 (file)
@@ -138,7 +138,7 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk)
            sbp->sb_blocksize > XFS_MAX_BLOCKSIZE                       ||
            sbp->sb_blocklog < XFS_MIN_BLOCKSIZE_LOG                    ||
            sbp->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG                    ||
-           sbp->sb_blocksize != (1 << sbp->sb_blocklog)                ||
+           sbp->sb_blocksize != (1ULL << sbp->sb_blocklog)             ||
            sbp->sb_inodesize < XFS_DINODE_MIN_SIZE                     ||
            sbp->sb_inodesize > XFS_DINODE_MAX_SIZE                     ||
            sbp->sb_inodelog < XFS_DINODE_MIN_LOG                       ||
index 595bfe48a7fa182daab6b0db61b39d905989b66d..7d55b5488f91f8a4ba2f42eaeec7c9af0975bda0 100644 (file)
@@ -361,7 +361,7 @@ static char *mk_string_list(char *ptr, size_t *len, size_t *begin,
                        return ptr;
                }
 
-               if (*begin + *run == cur) {     /* no gap, continue */
+               if (*begin + *run == (size_t)cur) {     /* no gap, continue */
                        (*run)++;
                        return ptr;
                }
index 89839069f913c5d11e2da836d13711a9fab96b68..88b9f8afb66f35e65b8709b6a614d5db1eeba5cc 100644 (file)
@@ -432,7 +432,7 @@ int fdisk_is_labeltype(struct fdisk_context *cxt, enum fdisk_labeltype id)
 {
        assert(cxt);
 
-       return cxt->label && fdisk_label_get_type(cxt->label) == id;
+       return cxt->label && (unsigned)fdisk_label_get_type(cxt->label) == id;
 }
 
 /**
@@ -715,7 +715,7 @@ int fdisk_is_readonly(struct fdisk_context *cxt)
  */
 void fdisk_unref_context(struct fdisk_context *cxt)
 {
-       int i;
+       unsigned i;
 
        if (!cxt)
                return;
index d4d66f63967f230641a07161aed53691b8edef6c..2f3a37bcba3e97ce158ad615fe1de7ec1536fbd6 100644 (file)
@@ -1788,7 +1788,7 @@ static int dos_locate_disklabel(struct fdisk_context *cxt, int n,
                break;
        default:
                /* extended partitions */
-               if (n - 1 + 4 < cxt->label->nparts_max) {
+               if ((size_t)n - 1 + 4 < cxt->label->nparts_max) {
                        struct pte *pe = self_pte(cxt, n - 1 + 4);
 
                        assert(pe->private_sectorbuffer);
index c461bb511785f7ff2ae5dadd4facb5386278eeea..f795b35a2617f28d752e243eb0015f94c3c3ab40 100644 (file)
@@ -810,7 +810,7 @@ static ssize_t read_lba(struct fdisk_context *cxt, uint64_t lba,
 
        if (lseek(cxt->dev_fd, offset, SEEK_SET) == (off_t) -1)
                return -1;
-       return read(cxt->dev_fd, buffer, bytes) != bytes;
+       return (size_t)read(cxt->dev_fd, buffer, bytes) != bytes;
 }
 
 
index 6fba120df95e419e7daa9417327d0c59fea67c24..3ca3f597fc98341d6aec20b3aca0a4a25c734963 100644 (file)
@@ -554,7 +554,7 @@ static int write_file_json(struct fdisk_script *dp, FILE *f)
                if (fdisk_partition_is_bootable(pa))
                        fprintf(f, ", \"bootable\": true");
 
-               if (ct < fdisk_table_get_nents(dp->table))
+               if ((size_t)ct < fdisk_table_get_nents(dp->table))
                        fputs("},\n", f);
                else
                        fputs("}\n", f);
index 8b4d9ed58e359224350c35efc159bc1927df1dd3..5ba9e046680e5db589e7049b5fbbc4c5fa8a1b9f 100644 (file)
@@ -30,7 +30,7 @@ static int read_from_device(struct fdisk_context *cxt,
        }
 
        r = read(cxt->dev_fd, buf, size);
-       if (r < 0 || r != size) {
+       if (r < 0 || (size_t)r != size) {
                if (!errno)
                        errno = EINVAL; /* probably too small file/device */
                DBG(CXT, ul_debugobj(cxt, "failed to read %zu from offset %ju: %m",
index cc19e4ab20f17f9d2fcf420c8f9e63b6086a796c..59684789ebddf90c79fc3fd1524f7cb0d430792f 100644 (file)
@@ -330,7 +330,7 @@ int scols_table_next_column(struct libscols_table *tb,
  */
 int scols_table_get_ncols(struct libscols_table *tb)
 {
-       return tb ? tb->ncols : -EINVAL;
+       return tb ? (int)tb->ncols : -EINVAL;
 }
 
 /**
@@ -341,7 +341,7 @@ int scols_table_get_ncols(struct libscols_table *tb)
  */
 int scols_table_get_nlines(struct libscols_table *tb)
 {
-       return tb ? tb->nlines : -EINVAL;
+       return tb ? (int)tb->nlines : -EINVAL;
 }
 
 /**
index 55306389a768f2c764a0338c46b55d2c3c4ee4f3..8803c73d98cf1f1d5ad237870bca2d8cce0dde92 100644 (file)
@@ -750,7 +750,7 @@ static int print_title(struct libscols_table *tb)
                        &width, align,
                        0, (int) *tb->symbols->title_padding);
 
-       if (rc == (size_t) -1) {
+       if (rc == -1) {
                rc = -EINVAL;
                goto done;
        }
index e4392661203fb14a00254a3043aeffe8fd075ad2..e6189d4b77bb68453d985a856ca47287e6ca19a2 100644 (file)
@@ -405,7 +405,7 @@ static const char *rfc3164_current_time(void)
 }
 
 #define next_iovec(ary, idx) __extension__ ({          \
-               assert(ARRAY_SIZE(ary) > idx);  \
+               assert(ARRAY_SIZE(ary) > (size_t)idx);  \
                assert(idx >= 0);                       \
                &ary[idx++];                            \
 })