diff options
author | Karel Zak | 2011-08-02 13:28:04 +0200 |
---|---|---|
committer | Karel Zak | 2011-08-02 13:28:04 +0200 |
commit | 538a2fe950fb534ba0db4cca144c01f58815e498 (patch) | |
tree | d7f25be54d7b8cc263254dbb3b47a396fed1305c /libblkid | |
parent | libblkid: [partitions] fix compiler warnings [-Wunused-parameter -Wsign-compare] (diff) | |
download | kernel-qcow2-util-linux-538a2fe950fb534ba0db4cca144c01f58815e498.tar.gz kernel-qcow2-util-linux-538a2fe950fb534ba0db4cca144c01f58815e498.tar.xz kernel-qcow2-util-linux-538a2fe950fb534ba0db4cca144c01f58815e498.zip |
libblkid: [superblocks] fix compiler warnings [-Wunused-parameter -Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid')
22 files changed, 83 insertions, 57 deletions
diff --git a/libblkid/src/superblocks/adaptec_raid.c b/libblkid/src/superblocks/adaptec_raid.c index 570e75e9f..02e900df0 100644 --- a/libblkid/src/superblocks/adaptec_raid.c +++ b/libblkid/src/superblocks/adaptec_raid.c @@ -73,7 +73,8 @@ struct adaptec_metadata { #define AD_SIGNATURE 0x4450544D /* "DPTM" */ #define AD_MAGIC 0x37FC4D1E -static int probe_adraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_adraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct adaptec_metadata *ad; diff --git a/libblkid/src/superblocks/befs.c b/libblkid/src/superblocks/befs.c index c78dc208e..62414ec61 100644 --- a/libblkid/src/superblocks/befs.c +++ b/libblkid/src/superblocks/befs.c @@ -158,9 +158,9 @@ unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_block *bs, const struct data_stream *ds, int64_t start, uint32_t length, int fs_le) { - if (start < FS64_TO_CPU(ds->max_direct_range, fs_le)) { + if (start < (int64_t) FS64_TO_CPU(ds->max_direct_range, fs_le)) { int64_t br_len; - int i; + size_t i; for (i = 0; i < NUM_DIRECT_BLOCKS; i++) { br_len = (int64_t) FS16_TO_CPU(ds->direct[i].len, fs_le) @@ -172,7 +172,7 @@ unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_block *bs, else start -= br_len; } - } else if (start < FS64_TO_CPU(ds->max_indirect_range, fs_le)) { + } else if (start < (int64_t) FS64_TO_CPU(ds->max_indirect_range, fs_le)) { struct block_run *br; int64_t max_br, br_len, i; @@ -195,11 +195,11 @@ unsigned char *get_tree_node(blkid_probe pr, const struct befs_super_block *bs, else start -= br_len; } - } else if (start < FS64_TO_CPU(ds->max_double_indirect_range, fs_le)) { + } else if (start < (int64_t) FS64_TO_CPU(ds->max_double_indirect_range, fs_le)) { struct block_run *br; int64_t di_br_size, br_per_di_br, di_index, i_index; - start -= FS64_TO_CPU(ds->max_indirect_range, fs_le); + start -= (int64_t) FS64_TO_CPU(ds->max_indirect_range, fs_le); di_br_size = (int64_t) FS16_TO_CPU(ds->double_indirect.len, fs_le) << FS32_TO_CPU(bs->block_shift, fs_le); br_per_di_br = di_br_size / sizeof(struct block_run); @@ -259,7 +259,7 @@ int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs, if (!bh) return -1; - if (FS32_TO_CPU(bh->magic, fs_le) != BPLUSTREE_MAGIC) + if ((int32_t) FS32_TO_CPU(bh->magic, fs_le) != BPLUSTREE_MAGIC) return -1; node_pointer = FS64_TO_CPU(bh->root_node_pointer, fs_le); @@ -285,7 +285,7 @@ int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs, cmp = compare_keys(bn->name, keylengths, last, key, strlen(key), fs_le); if (cmp == 0) { - if (FS64_TO_CPU(bn->overflow_link, fs_le) + if ((int64_t) FS64_TO_CPU(bn->overflow_link, fs_le) == BPLUSTREE_NULL) return FS64_TO_CPU(values[last], fs_le); else @@ -299,7 +299,7 @@ int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs, cmp = compare_keys(bn->name, keylengths, mid, key, strlen(key), fs_le); if (cmp == 0) { - if (FS64_TO_CPU(bn->overflow_link, + if ((int64_t) FS64_TO_CPU(bn->overflow_link, fs_le) == BPLUSTREE_NULL) return FS64_TO_CPU(values[mid], fs_le); @@ -316,7 +316,8 @@ int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs, else node_pointer = FS64_TO_CPU(values[mid], fs_le); } - } while (FS64_TO_CPU(bn->overflow_link, fs_le) != BPLUSTREE_NULL); + } while ((int64_t) FS64_TO_CPU(bn->overflow_link, fs_le) + != BPLUSTREE_NULL); return 0; } @@ -355,8 +356,8 @@ int get_uuid(blkid_probe pr, const struct befs_super_block *bs, + FS16_TO_CPU(sd->data_size, fs_le) + 1); } while ((intptr_t) sd < (intptr_t) bi - + FS32_TO_CPU(bi->inode_size, fs_le) - - sizeof(struct small_data)); + + (int32_t) FS32_TO_CPU(bi->inode_size, fs_le) + - (int32_t) sizeof(struct small_data)); if (*uuid == 0 && (FS32_TO_CPU(bi->attributes.allocation_group, fs_le) != 0 || FS16_TO_CPU(bi->attributes.start, fs_le) != 0 diff --git a/libblkid/src/superblocks/ddf_raid.c b/libblkid/src/superblocks/ddf_raid.c index c0ba33517..24df421d1 100644 --- a/libblkid/src/superblocks/ddf_raid.c +++ b/libblkid/src/superblocks/ddf_raid.c @@ -71,10 +71,11 @@ struct ddf_header { uint8_t pad4[256]; /* 0xff */ } __attribute__((packed)); -static int probe_ddf(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ddf(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { int hdrs[] = { 1, 257 }; - int i; + size_t i; struct ddf_header *ddf = NULL; char version[DDF_REV_LENGTH + 1]; uint64_t off, lba; diff --git a/libblkid/src/superblocks/drbd.c b/libblkid/src/superblocks/drbd.c index 3490948de..1e404069b 100644 --- a/libblkid/src/superblocks/drbd.c +++ b/libblkid/src/superblocks/drbd.c @@ -64,7 +64,8 @@ struct md_on_disk_08 { }; -static int probe_drbd(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_drbd(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct md_on_disk_08 *md; off_t off; diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c index 6dfe52831..4066347cd 100644 --- a/libblkid/src/superblocks/ext.c +++ b/libblkid/src/superblocks/ext.c @@ -311,7 +311,8 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es) } -static int probe_jbd(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_jbd(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct ext2_super_block *es; uint32_t fi; @@ -326,7 +327,8 @@ static int probe_jbd(blkid_probe pr, const struct blkid_idmag *mag) return 0; } -static int probe_ext2(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ext2(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct ext2_super_block *es; uint32_t fc, frc, fi; @@ -357,7 +359,8 @@ static int probe_ext2(blkid_probe pr, const struct blkid_idmag *mag) return 0; } -static int probe_ext3(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ext3(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct ext2_super_block *es; uint32_t fc, frc, fi; @@ -380,7 +383,8 @@ static int probe_ext3(blkid_probe pr, const struct blkid_idmag *mag) } -static int probe_ext4dev(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ext4dev(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct ext2_super_block *es; uint32_t fc, frc, fi; @@ -425,7 +429,8 @@ force_ext4dev: return 0; } -static int probe_ext4(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ext4(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct ext2_super_block *es; uint32_t fc, frc, fi; diff --git a/libblkid/src/superblocks/highpoint_raid.c b/libblkid/src/superblocks/highpoint_raid.c index 25e3114b3..0b41344ae 100644 --- a/libblkid/src/superblocks/highpoint_raid.c +++ b/libblkid/src/superblocks/highpoint_raid.c @@ -22,7 +22,8 @@ struct hpt45x_metadata { #define HPT45X_MAGIC_OK 0x5a7816f3 #define HPT45X_MAGIC_BAD 0x5a7816fd -static int probe_highpoint45x(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_highpoint45x(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct hpt45x_metadata *hpt; uint64_t off; @@ -49,7 +50,8 @@ static int probe_highpoint45x(blkid_probe pr, const struct blkid_idmag *mag) return 0; } -static int probe_highpoint37x(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_highpoint37x(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) return -1; diff --git a/libblkid/src/superblocks/iso9660.c b/libblkid/src/superblocks/iso9660.c index 9f3ce2e60..36bf07713 100644 --- a/libblkid/src/superblocks/iso9660.c +++ b/libblkid/src/superblocks/iso9660.c @@ -54,7 +54,7 @@ struct high_sierra_volume_descriptor { static int ascii_eq_utf16be(unsigned char *ascii, unsigned char *utf16, size_t len) { - int a, u; + size_t a, u; for (a = 0, u = 0; u < len; a++, u += 2) { if (utf16[u] != 0x0 || ascii[a] != utf16[u + 1]) diff --git a/libblkid/src/superblocks/isw_raid.c b/libblkid/src/superblocks/isw_raid.c index ac6251d7c..755c1b652 100644 --- a/libblkid/src/superblocks/isw_raid.c +++ b/libblkid/src/superblocks/isw_raid.c @@ -26,7 +26,8 @@ struct isw_metadata { #define ISW_SIGNATURE "Intel Raid ISM Cfg Sig. " -static int probe_iswraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_iswraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct isw_metadata *isw; diff --git a/libblkid/src/superblocks/jfs.c b/libblkid/src/superblocks/jfs.c index 9a49c6746..78c018c15 100644 --- a/libblkid/src/superblocks/jfs.c +++ b/libblkid/src/superblocks/jfs.c @@ -41,9 +41,9 @@ static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag) js = blkid_probe_get_sb(pr, mag, struct jfs_super_block); if (!js) return -1; - if (le32_to_cpu(js->js_bsize) != (1 << le16_to_cpu(js->js_l2bsize))) + if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize))) return 1; - if (le32_to_cpu(js->js_pbsize) != (1 << le16_to_cpu(js->js_l2pbsize))) + if (le32_to_cpu(js->js_pbsize) != (1U << le16_to_cpu(js->js_l2pbsize))) return 1; if ((le16_to_cpu(js->js_l2bsize) - le16_to_cpu(js->js_l2pbsize)) != le16_to_cpu(js->js_l2bfactor)) diff --git a/libblkid/src/superblocks/jmicron_raid.c b/libblkid/src/superblocks/jmicron_raid.c index d35b17f89..c7080780f 100644 --- a/libblkid/src/superblocks/jmicron_raid.c +++ b/libblkid/src/superblocks/jmicron_raid.c @@ -25,7 +25,8 @@ struct jm_metadata { #define JM_SIGNATURE "JM" -static int probe_jmraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_jmraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct jm_metadata *jm; diff --git a/libblkid/src/superblocks/linux_raid.c b/libblkid/src/superblocks/linux_raid.c index e74f57de9..609d24bf7 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, blkid_loff_t off) size <<= 10; /* convert KiB to bytes */ - if (pr->size < size + MD_RESERVED_BYTES) + if (pr->size < 0 || (uint64_t) pr->size < size + MD_RESERVED_BYTES) /* device is too small */ return 1; - if (off < size) + if (off < 0 || (uint64_t) off < size) /* no space before superblock */ return 1; @@ -194,9 +194,9 @@ static int probe_raid1(blkid_probe pr, off_t off) return -1; if (le32_to_cpu(mdp1->magic) != MD_SB_MAGIC) return -1; - if (le32_to_cpu(mdp1->major_version) != 1) + if (le32_to_cpu(mdp1->major_version) != 1U) return -1; - if (le64_to_cpu(mdp1->super_offset) != off >> 9) + if (le64_to_cpu(mdp1->super_offset) != (uint64_t) off >> 9) return -1; if (blkid_probe_set_uuid(pr, (unsigned char *) mdp1->set_uuid) != 0) return -1; @@ -212,7 +212,8 @@ static int probe_raid1(blkid_probe pr, off_t off) return 0; } -int probe_raid(blkid_probe pr, const struct blkid_idmag *mag) +int probe_raid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { const char *ver = NULL; diff --git a/libblkid/src/superblocks/lsi_raid.c b/libblkid/src/superblocks/lsi_raid.c index 5217a0093..56721dd71 100644 --- a/libblkid/src/superblocks/lsi_raid.c +++ b/libblkid/src/superblocks/lsi_raid.c @@ -23,7 +23,8 @@ struct lsi_metadata { #define LSI_SIGNATURE "$XIDE$" -static int probe_lsiraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_lsiraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct lsi_metadata *lsi; diff --git a/libblkid/src/superblocks/nvidia_raid.c b/libblkid/src/superblocks/nvidia_raid.c index c3db949a8..dd86cdcc6 100644 --- a/libblkid/src/superblocks/nvidia_raid.c +++ b/libblkid/src/superblocks/nvidia_raid.c @@ -25,7 +25,8 @@ struct nv_metadata { #define NVIDIA_SIGNATURE "NVIDIA" -static int probe_nvraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_nvraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct nv_metadata *nv; diff --git a/libblkid/src/superblocks/promise_raid.c b/libblkid/src/superblocks/promise_raid.c index 0e91d3c25..221146dbc 100644 --- a/libblkid/src/superblocks/promise_raid.c +++ b/libblkid/src/superblocks/promise_raid.c @@ -24,7 +24,8 @@ struct promise_metadata { #define PDC_CONFIG_OFF 0x1200 #define PDC_SIGNATURE "Promise Technology, Inc." -static int probe_pdcraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_pdcraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { unsigned int i; static unsigned int sectors[] = { diff --git a/libblkid/src/superblocks/silicon_raid.c b/libblkid/src/superblocks/silicon_raid.c index b72b72760..fef58010c 100644 --- a/libblkid/src/superblocks/silicon_raid.c +++ b/libblkid/src/superblocks/silicon_raid.c @@ -41,7 +41,8 @@ struct silicon_metadata { #define SILICON_MAGIC 0x2F000000 -static int probe_silraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_silraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct silicon_metadata *sil; diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index 9b618b28f..8a0edaa7c 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -251,7 +251,7 @@ int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage) { unsigned long *fltr; struct blkid_chain *chn; - int i; + size_t i; if (!pr) return -1; @@ -283,7 +283,7 @@ int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage) */ int blkid_known_fstype(const char *fstype) { - int i; + size_t i; if (!fstype) return 0; @@ -306,7 +306,7 @@ int blkid_known_fstype(const char *fstype) */ int blkid_superblocks_get_name(size_t idx, const char **name, int *usage) { - if (idx >= 0 && idx < ARRAY_SIZE(idinfos)) { + if (idx < ARRAY_SIZE(idinfos)) { if (name) *name = idinfos[idx]->name; if (usage) @@ -321,7 +321,7 @@ int blkid_superblocks_get_name(size_t idx, const char **name, int *usage) */ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) { - int i = 0; + size_t i; if (!pr || chn->idx < -1) return -1; @@ -337,7 +337,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) * is 1 byte */ goto nothing; - i = chn->idx + 1; + i = chn->idx < 0 ? 0 : chn->idx + 1U; for ( ; i < ARRAY_SIZE(idinfos); i++) { const struct blkid_idinfo *id; @@ -366,7 +366,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) if ((id->usage & BLKID_USAGE_RAID) && blkid_probe_is_tiny(pr)) continue; - DBG(DEBUG_LOWPROBE, printf("[%d] %s:\n", i, id->name)); + DBG(DEBUG_LOWPROBE, printf("[%zd] %s:\n", i, id->name)); if (blkid_probe_get_idmag(pr, id, &off, &mag)) continue; @@ -593,7 +593,7 @@ int blkid_probe_set_utf8label(blkid_probe pr, unsigned char *label, /* like uuid_is_null() from libuuid, but works with arbitrary size of UUID */ static int uuid_is_empty(const unsigned char *buf, size_t len) { - int i; + size_t i; for (i = 0; i < len; i++) if (buf[i]) @@ -626,7 +626,7 @@ int blkid_probe_sprintf_uuid(blkid_probe pr, unsigned char *uuid, /* convert to lower case (..be paranoid) */ if (!rc) { - int i; + size_t i; struct blkid_prval *v = __blkid_probe_get_value(pr, blkid_probe_numof_values(pr)); if (v) { diff --git a/libblkid/src/superblocks/sysv.c b/libblkid/src/superblocks/sysv.c index 00c8c978b..80b0cc542 100644 --- a/libblkid/src/superblocks/sysv.c +++ b/libblkid/src/superblocks/sysv.c @@ -90,11 +90,12 @@ static int probe_xenix(blkid_probe pr, const struct blkid_idmag *mag) /* Note that we don't probe for Coherent FS, this FS does not have * magic string. (It requires to probe fname/fpack field..) */ -static int probe_sysv(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_sysv(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct sysv_super_block *sb; int blocks[] = {0, 9, 15, 18}; - int i; + size_t i; for (i = 0; i < ARRAY_SIZE(blocks); i++) { int off = blocks[i] * SYSV_BLOCK_SIZE + SYSV_BLOCK_SIZE/2; diff --git a/libblkid/src/superblocks/udf.c b/libblkid/src/superblocks/udf.c index 766d6980f..a5afc5c58 100644 --- a/libblkid/src/superblocks/udf.c +++ b/libblkid/src/superblocks/udf.c @@ -57,7 +57,8 @@ struct volume_structure_descriptor { #define UDF_VSD_OFFSET 0x8000LL -static int probe_udf(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_udf(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { struct volume_descriptor *vd; struct volume_structure_descriptor *vsd; diff --git a/libblkid/src/superblocks/ufs.c b/libblkid/src/superblocks/ufs.c index 05bed1451..3ace715e9 100644 --- a/libblkid/src/superblocks/ufs.c +++ b/libblkid/src/superblocks/ufs.c @@ -163,20 +163,21 @@ struct ufs_super_block { #define UFS_MAGIC_SEC 0x00612195 #define UFS_MAGIC_4GB 0x05231994 -static int probe_ufs(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_ufs(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { int offsets[] = { 0, 8, 64, 256 }; - int mags[] = { + uint32_t mags[] = { UFS2_MAGIC, UFS_MAGIC, UFS_MAGIC_FEA, UFS_MAGIC_LFN, UFS_MAGIC_SEC, UFS_MAGIC_4GB }; - int i; + size_t i; uint32_t magic; struct ufs_super_block *ufs; for (i = 0; i < ARRAY_SIZE(offsets); i++) { uint32_t magLE, magBE; - int y; + size_t y; ufs = (struct ufs_super_block *) blkid_probe_get_buffer(pr, diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c index bf474630d..13d576953 100644 --- a/libblkid/src/superblocks/vfat.c +++ b/libblkid/src/superblocks/vfat.c @@ -121,7 +121,7 @@ static unsigned char *search_fat_label(blkid_probe pr, uint64_t offset, uint32_t entries) { struct vfat_dir_entry *ent, *dir = NULL; - int i; + uint32_t i; DBG(DEBUG_LOWPROBE, printf("\tlook for label in root-dir " diff --git a/libblkid/src/superblocks/via_raid.c b/libblkid/src/superblocks/via_raid.c index 201313801..eba7e4bf2 100644 --- a/libblkid/src/superblocks/via_raid.c +++ b/libblkid/src/superblocks/via_raid.c @@ -45,7 +45,8 @@ static uint8_t via_checksum(struct via_metadata *v) return cs == v->checksum; } -static int probe_viaraid(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_viaraid(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t off; struct via_metadata *v; diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c index af5264d46..b96c5df45 100644 --- a/libblkid/src/superblocks/zfs.c +++ b/libblkid/src/superblocks/zfs.c @@ -70,7 +70,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset) { struct nvlist *nvl; struct nvpair *nvp; - int left = 4096; + size_t left = 4096; int found = 0; offset = (offset & ~(VDEV_LABEL_SIZE - 1)) + VDEV_LABEL_NVPAIR; @@ -94,7 +94,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset) nvp->nvp_namelen = be32_to_cpu(nvp->nvp_namelen); avail = nvp->nvp_size - nvp->nvp_namelen - sizeof(*nvp); - nvdebug("left %u, nvp_size %u\n", left, nvp->nvp_size); + nvdebug("left %zd nvp_size %u\n", left, nvp->nvp_size); if (left < nvp->nvp_size || avail < 0) break; @@ -148,7 +148,10 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset) "%"PRIu64, nvu_value); found++; } - left -= nvp->nvp_size; + if (left > nvp->nvp_size) + left -= nvp->nvp_size; + else + left = 0; nvp = (struct nvpair *)((char *)nvp + nvp->nvp_size); } } @@ -159,7 +162,8 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset) /* ZFS has 128x1kB host-endian root blocks, stored in 2 areas at the start * of the disk, and 2 areas at the end of the disk. Check only some of them... * #4 (@ 132kB) is the first one written on a new filesystem. */ -static int probe_zfs(blkid_probe pr, const struct blkid_idmag *mag) +static int probe_zfs(blkid_probe pr, + const struct blkid_idmag *mag __attribute__((__unused__))) { uint64_t swab_magic = swab64(UBERBLOCK_MAGIC); struct zfs_uberblock *ub; |