summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuediger Meier2016-02-23 00:54:41 +0100
committerRuediger Meier2016-02-23 03:18:27 +0100
commitb9710f1f0850100e59503729f6e12eaa0ded7314 (patch)
treed56442407f5330dbcec32074983b32dd1fe730e5
parentmisc: fix warnings "unused parameter" [-Wunused-parameter] (diff)
downloadkernel-qcow2-util-linux-b9710f1f0850100e59503729f6e12eaa0ded7314.tar.gz
kernel-qcow2-util-linux-b9710f1f0850100e59503729f6e12eaa0ded7314.tar.xz
kernel-qcow2-util-linux-b9710f1f0850100e59503729f6e12eaa0ded7314.zip
misc: fix compiler warnungs (unsigned/signed)
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>
-rw-r--r--disk-utils/partx.c6
-rw-r--r--libblkid/src/partitions/partitions.c16
-rw-r--r--libblkid/src/probe.c6
-rw-r--r--libblkid/src/superblocks/linux_raid.c4
-rw-r--r--libblkid/src/superblocks/superblocks.c2
-rw-r--r--libblkid/src/superblocks/xfs.c2
-rw-r--r--libfdisk/src/ask.c2
-rw-r--r--libfdisk/src/context.c4
-rw-r--r--libfdisk/src/dos.c2
-rw-r--r--libfdisk/src/gpt.c2
-rw-r--r--libfdisk/src/script.c2
-rw-r--r--libfdisk/src/utils.c2
-rw-r--r--libsmartcols/src/table.c4
-rw-r--r--libsmartcols/src/table_print.c2
-rw-r--r--misc-utils/logger.c2
15 files changed, 29 insertions, 29 deletions
diff --git a/disk-utils/partx.c b/disk-utils/partx.c
index ffc74d698..f01cf22c5 100644
--- a/disk-utils/partx.c
+++ b/disk-utils/partx.c
@@ -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)) {
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
index 7c37dfb96..c8e0bfeb0 100644
--- a/libblkid/src/partitions/partitions.c
+++ b/libblkid/src/partitions/partitions.c
@@ -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;
}
/**
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 5f15b0981..cc4586bf2 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -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);
diff --git a/libblkid/src/superblocks/linux_raid.c b/libblkid/src/superblocks/linux_raid.c
index e60c5e597..e6b496a35 100644
--- a/libblkid/src/superblocks/linux_raid.c
+++ b/libblkid/src/superblocks/linux_raid.c
@@ -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;
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 2b850305d..987a647d5 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -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 */
}
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index 575651b22..01e9cda82 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -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 ||
diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c
index 595bfe48a..7d55b5488 100644
--- a/libfdisk/src/ask.c
+++ b/libfdisk/src/ask.c
@@ -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;
}
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 89839069f..88b9f8afb 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -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;
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index d4d66f639..2f3a37bcb 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -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);
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index c461bb511..f795b35a2 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -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;
}
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
index 6fba120df..3ca3f597f 100644
--- a/libfdisk/src/script.c
+++ b/libfdisk/src/script.c
@@ -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);
diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c
index 8b4d9ed58..5ba9e0466 100644
--- a/libfdisk/src/utils.c
+++ b/libfdisk/src/utils.c
@@ -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",
diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c
index cc19e4ab2..59684789e 100644
--- a/libsmartcols/src/table.c
+++ b/libsmartcols/src/table.c
@@ -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;
}
/**
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index 55306389a..8803c73d9 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -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;
}
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index e43926612..e6189d4b7 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -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++]; \
})