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>
This commit is contained in:
parent
71177ab8f9
commit
b9710f1f08
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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++]; \
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue