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];
}
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 */
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)) {
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;
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;
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;
*/
blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
{
- return tab ? tab->offset : -1;
+ return tab ? (blkid_loff_t)tab->offset : -1;
}
/**
*/
blkid_loff_t blkid_partition_get_start(blkid_partition par)
{
- return par ? par->start : -1;
+ return par ? (blkid_loff_t)par->start : -1;
}
/**
*/
blkid_loff_t blkid_partition_get_size(blkid_partition par)
{
- return par ? par->size : -1;
+ return par ? (blkid_loff_t)par->size : -1;
}
/**
{
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;
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 */
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);
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;
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 */
}
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 ||
return ptr;
}
- if (*begin + *run == cur) { /* no gap, continue */
+ if (*begin + *run == (size_t)cur) { /* no gap, continue */
(*run)++;
return ptr;
}
{
assert(cxt);
- return cxt->label && fdisk_label_get_type(cxt->label) == id;
+ return cxt->label && (unsigned)fdisk_label_get_type(cxt->label) == id;
}
/**
*/
void fdisk_unref_context(struct fdisk_context *cxt)
{
- int i;
+ unsigned i;
if (!cxt)
return;
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);
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;
}
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);
}
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",
*/
int scols_table_get_ncols(struct libscols_table *tb)
{
- return tb ? tb->ncols : -EINVAL;
+ return tb ? (int)tb->ncols : -EINVAL;
}
/**
*/
int scols_table_get_nlines(struct libscols_table *tb)
{
- return tb ? tb->nlines : -EINVAL;
+ return tb ? (int)tb->nlines : -EINVAL;
}
/**
&width, align,
0, (int) *tb->symbols->title_padding);
- if (rc == (size_t) -1) {
+ if (rc == -1) {
rc = -EINVAL;
goto done;
}
}
#define next_iovec(ary, idx) __extension__ ({ \
- assert(ARRAY_SIZE(ary) > idx); \
+ assert(ARRAY_SIZE(ary) > (size_t)idx); \
assert(idx >= 0); \
&ary[idx++]; \
})