diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 049b0e5f..d94f4eb2 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -694,7 +694,7 @@ void dump_resident_attr_val(ATTR_TYPES type, char *val, u32 val_len) default: i = le32_to_cpu(type); printf("Cannot display unknown %s defined attribute type 0x%x" - ".\n", i >= + ".\n", (u32)i >= le32_to_cpu(AT_FIRST_USER_DEFINED_ATTRIBUTE) ? "user" : "system", i); } @@ -809,7 +809,7 @@ void dump_attr_record(ATTR_RECORD *a) if (a->name_length) { if (ucstos(s, (uchar_t*)((char*)a + cpu_to_le16(a->name_offset)), - min(sizeof(s), a->name_length + 1)) == -1) { + min(sizeof(s), a->name_length + 1U)) == -1) { Eprintf("Could not convert Unicode string to single " "byte string in current locale.\n"); strncpy(s, "Error converting Unicode string", @@ -1067,7 +1067,7 @@ runlist *allocate_scattered_clusters(s64 clusters) * Reallocate memory if necessary. Make sure we have * enough for the terminator entry as well. */ - if ((rlpos + 2) * sizeof(runlist) >= rlsize) { + if ((rlpos + 2) * (int)sizeof(runlist) >= rlsize) { rlsize += 4096; /* PAGE_SIZE */ rlt = realloc(rl, rlsize); if (!rlt) @@ -1905,7 +1905,7 @@ int add_attr_index_root(MFT_RECORD *m, const char *name, const u32 name_len, free(r); return -EINVAL; } - if (index_block_size < opts.sector_size) { + if (index_block_size < (u32)opts.sector_size) { Eprintf("add_attr_index_root: index block size is " "smaller than the sector size.\n"); free(r); @@ -2445,7 +2445,7 @@ int create_hardlink(INDEX_BLOCK *index, const MFT_REF ref_parent, /** * init_options */ -void init_options() +void init_options(void) { memset(&opts, 0, sizeof(opts)); opts.index_block_size = 4096; @@ -2679,13 +2679,13 @@ int main(int argc, char **argv) else vol->cluster_size = 4096; /* For small volumes on devices with large sector sizes. */ - if (vol->cluster_size < opts.sector_size) + if (vol->cluster_size < (u32)opts.sector_size) vol->cluster_size = opts.sector_size; } /* Validate cluster size. */ if (vol->cluster_size & (vol->cluster_size - 1) || - vol->cluster_size < opts.sector_size || - vol->cluster_size > 128 * opts.sector_size || + vol->cluster_size < (u32)opts.sector_size || + vol->cluster_size > 128 * (u32)opts.sector_size || vol->cluster_size > 65536) err_exit("Error: cluster_size is invalid. It must be a power " "of two, be at least\nthe same as sector_size, be " @@ -2967,7 +2967,7 @@ int main(int argc, char **argv) fflush(stdout); } bw = mkntfs_write(vol->dev, buf, vol->cluster_size); - if (bw != vol->cluster_size) { + if (bw != (ssize_t)vol->cluster_size) { if (bw != -1 || errno != EIO) err_exit("This should not happen.\n"); if (!position) @@ -2996,12 +2996,12 @@ int main(int argc, char **argv) Qprintf("\b\b\b\b100%%"); position = (opts.volume_size & (vol->cluster_size - 1)) / opts.sector_size; - for (i = 0; i < position; i++) { + for (i = 0; (unsigned long)i < position; i++) { bw = mkntfs_write(vol->dev, buf, opts.sector_size); if (bw != opts.sector_size) { if (bw != -1 || errno != EIO) err_exit("This should not happen.\n"); - else if (i + 1 == position && + else if (i + 1UL == position && (vol->major_ver >= 2 || (vol->major_ver == 1 && vol->minor_ver >= 2))) @@ -3264,7 +3264,8 @@ int main(int argc, char **argv) vol->cluster_size; else { bs->clusters_per_mft_record = -(ffs(vol->mft_record_size) - 1); - if ((1 << -bs->clusters_per_mft_record) != vol->mft_record_size) + if ((u32)(1 << -bs->clusters_per_mft_record) != + vol->mft_record_size) err_exit("BUG: calculated clusters_per_mft_record " "is wrong (= 0x%x)\n", bs->clusters_per_mft_record); @@ -3272,7 +3273,7 @@ int main(int argc, char **argv) Dprintf("Clusters per mft record = %i (0x%x)\n", bs->clusters_per_mft_record, bs->clusters_per_mft_record); - if (opts.index_block_size >= vol->cluster_size) + if (opts.index_block_size >= (int)vol->cluster_size) bs->clusters_per_index_record = opts.index_block_size / vol->cluster_size; else { @@ -3491,7 +3492,7 @@ bb_err: Vprintf("Syncing $MFT.\n"); pos = opts.mft_lcn * vol->cluster_size; lw = 1; - for (i = 0; i < opts.mft_size / vol->mft_record_size; i++) { + for (i = 0; i < opts.mft_size / (s32)vol->mft_record_size; i++) { if (!opts.no_action) lw = ntfs_mst_pwrite(vol->dev, pos, 1, vol->mft_record_size, diff --git a/ntfsprogs/ntfscluster.c b/ntfsprogs/ntfscluster.c index 0af3237a..95645025 100644 --- a/ntfsprogs/ntfscluster.c +++ b/ntfsprogs/ntfscluster.c @@ -350,7 +350,7 @@ int cluster_find (ntfs_volume *vol, LCN s_begin, LCN s_end) return 1; } - for (i = s_begin; i < s_end; i++) { + for (i = s_begin; (LCN)i < s_end; i++) { if (utils_cluster_in_use (vol, i) == 1) { in_use = 1; break; @@ -368,7 +368,7 @@ int cluster_find (ntfs_volume *vol, LCN s_begin, LCN s_end) // first, is the cluster in use in $Bitmap? - for (i = 0; i < vol->nr_mft_records; i++) { + for (i = 0; (s64)i < vol->nr_mft_records; i++) { ntfs_inode *inode; ntfs_attr_search_ctx *ctx; diff --git a/ntfsprogs/ntfslabel.c b/ntfsprogs/ntfslabel.c index 7da52ff1..1263f116 100644 --- a/ntfsprogs/ntfslabel.c +++ b/ntfsprogs/ntfslabel.c @@ -220,7 +220,7 @@ int resize_resident_attribute_value(MFT_RECORD *m, ATTR_RECORD *a, new_muse = le32_to_cpu(m->bytes_in_use) - le32_to_cpu(a->length) + new_alen; /* Check for sufficient space. */ - if (new_muse > le32_to_cpu(m->bytes_allocated)) { + if ((u32)new_muse > le32_to_cpu(m->bytes_allocated)) { errno = ENOSPC; return -1; } diff --git a/ntfsprogs/upcase.c b/ntfsprogs/upcase.c index 45ef8eea..7d57dc7d 100644 --- a/ntfsprogs/upcase.c +++ b/ntfsprogs/upcase.c @@ -71,7 +71,7 @@ void init_upcase_table(uchar_t *uc, u32 uc_len) memset((char*)uc, 0, uc_len); uc_len >>= 1; - for (i = 0; i < uc_len; i++) + for (i = 0; (u32)i < uc_len; i++) uc[i] = i; for (r = 0; uc_run_table[r][0]; r++) for (i = uc_run_table[r][0]; i < uc_run_table[r][1]; i++) diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index 22a4e26a..7ee3addd 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -675,7 +675,8 @@ int utils_mftrec_in_use (ntfs_volume *vol, MFT_REF mref) } /* Does mref lie in the section of $Bitmap we already have cached? */ - if ((mref < bmpmref) || (mref >= (bmpmref + (sizeof (buffer) << 3)))) { + if (((s64)MREF(mref) < bmpmref) || ((s64)MREF(mref) >= (bmpmref + + (sizeof (buffer) << 3)))) { Dprintf ("Bit lies outside cache.\n"); /* Mark the buffer as not in use, in case the read is shorter. */ @@ -760,7 +761,7 @@ ntfs_inode * utils_pathname_to_inode (ntfs_volume *vol, ntfs_inode *parent, cons } inum = ntfs_inode_lookup_by_name (ni, unicode, len); - if (inum == -1) { + if (inum == (u64)-1) { Eprintf ("Couldn't find name '%s' in pathname '%s'.\n", p, pathname); goto close; } @@ -912,7 +913,7 @@ int mft_next_record (struct mft_search_ctx *ctx) ctx->inode = NULL; } - for (ctx->mft_num++; ctx->mft_num < ctx->vol->nr_mft_records; ctx->mft_num++) { + for (ctx->mft_num++; (s64)ctx->mft_num < ctx->vol->nr_mft_records; ctx->mft_num++) { ctx->flags_match = 0; int in_use = utils_mftrec_in_use (ctx->vol, (MFT_REF) ctx->mft_num); if (in_use == -1) {