btrfs-progs: remove unnecessary casts for u64

The (unsigned long long) type casts can be dropped, printf understands
%llu and u64 and does not warn. In cases where the type is not u64 keep
the cast.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-09-28 01:13:00 +02:00
parent d35b7f87c4
commit b73a29936a
8 changed files with 38 additions and 71 deletions

View File

@ -54,8 +54,7 @@ static int debug_corrupt_block(struct extent_buffer *eb,
ret = -EIO;
if (ret < 0) {
errno = -ret;
error("cannot read eb bytenr %llu: %m",
(unsigned long long)eb->start);
error("cannot read eb bytenr %llu: %m", eb->start);
return ret;
}
printf("corrupting %llu copy %d\n", eb->start,
@ -64,8 +63,7 @@ static int debug_corrupt_block(struct extent_buffer *eb,
ret = write_and_map_eb(eb->fs_info, eb);
if (ret < 0) {
errno = -ret;
error("cannot write eb bytenr %llu: %m",
(unsigned long long)eb->start);
error("cannot write eb bytenr %llu: %m", eb->start);
return ret;
}
}
@ -153,7 +151,7 @@ static void corrupt_keys(struct btrfs_trans_handle *trans,
fprintf(stderr,
"corrupting keys in block %llu slot %d swapping with %d\n",
(unsigned long long)eb->start, slot, bad_slot);
eb->start, slot, bad_slot);
if (btrfs_header_level(eb) == 0) {
btrfs_item_key(eb, &bad_key, bad_slot);
@ -1601,7 +1599,7 @@ int main(int argc, char **argv)
if (!eb) {
error(
"not enough memory to allocate extent buffer for bytenr %llu",
(unsigned long long)logical);
logical);
ret = 1;
goto out_close;
}

View File

@ -96,8 +96,7 @@ int main(int argc, char **argv)
* transaction commit. We just want the super copy we pulled off the
* disk to overwrite all the other copies
*/
printf("using SB copy %llu, bytenr %llu\n", (unsigned long long)num,
(unsigned long long)bytenr);
printf("using SB copy %llu, bytenr %llu\n", num, bytenr);
close_ctree(root);
btrfs_close_all_devices();
return ret;

View File

@ -261,14 +261,10 @@ static int setup_temp_root_tree(int fd, struct btrfs_mkfs_config *cfg,
"extent < dev %llu < %llu, "
"dev < fs %llu < %llu, "
"fs < csum %llu < %llu",
(unsigned long long)root_bytenr,
(unsigned long long)extent_bytenr,
(unsigned long long)extent_bytenr,
(unsigned long long)dev_bytenr,
(unsigned long long)dev_bytenr,
(unsigned long long)fs_bytenr,
(unsigned long long)fs_bytenr,
(unsigned long long)csum_bytenr);
root_bytenr, extent_bytenr,
extent_bytenr, dev_bytenr,
dev_bytenr, fs_bytenr,
fs_bytenr, csum_bytenr);
return -EINVAL;
}
buf = malloc(sizeof(*buf) + cfg->nodesize);
@ -433,8 +429,7 @@ static int setup_temp_chunk_tree(int fd, struct btrfs_mkfs_config *cfg,
/* Must ensure SYS chunk starts before META chunk */
if (meta_chunk_start < sys_chunk_start) {
error("wrong chunk order: meta < system %llu < %llu",
(unsigned long long)meta_chunk_start,
(unsigned long long)sys_chunk_start);
meta_chunk_start, sys_chunk_start);
return -EINVAL;
}
buf = malloc(sizeof(*buf) + cfg->nodesize);
@ -504,8 +499,7 @@ static int setup_temp_dev_tree(int fd, struct btrfs_mkfs_config *cfg,
/* Must ensure SYS chunk starts before META chunk */
if (meta_chunk_start < sys_chunk_start) {
error("wrong chunk order: meta < system %llu < %llu",
(unsigned long long)meta_chunk_start,
(unsigned long long)sys_chunk_start);
meta_chunk_start, sys_chunk_start);
return -EINVAL;
}
buf = malloc(sizeof(*buf) + cfg->nodesize);
@ -712,16 +706,11 @@ static int setup_temp_extent_tree(int fd, struct btrfs_mkfs_config *cfg,
"extent < dev %llu < %llu, "
"dev < fs %llu < %llu, "
"fs < csum %llu < %llu",
(unsigned long long)chunk_bytenr,
(unsigned long long)root_bytenr,
(unsigned long long)root_bytenr,
(unsigned long long)extent_bytenr,
(unsigned long long)extent_bytenr,
(unsigned long long)dev_bytenr,
(unsigned long long)dev_bytenr,
(unsigned long long)fs_bytenr,
(unsigned long long)fs_bytenr,
(unsigned long long)csum_bytenr);
chunk_bytenr, root_bytenr,
root_bytenr, extent_bytenr,
extent_bytenr, dev_bytenr,
dev_bytenr, fs_bytenr,
fs_bytenr, csum_bytenr);
return -EINVAL;
}
buf = malloc(sizeof(*buf) + cfg->nodesize);

View File

@ -141,8 +141,7 @@ static void *print_copied_inodes(void *p)
pthread_mutex_lock(&priv->mutex);
printf("Copy inodes [%c] [%10llu/%10llu]\r",
work_indicator[count % 4],
(unsigned long long)priv->cur_copy_inodes,
(unsigned long long)priv->max_copy_inodes);
priv->cur_copy_inodes, priv->max_copy_inodes);
pthread_mutex_unlock(&priv->mutex);
fflush(stdout);
task_period_wait(priv->info);
@ -220,13 +219,11 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
u32 datacsum = convert_flags & CONVERT_FLAG_DATACSUM;
if (bytenr != round_down(bytenr, root->fs_info->sectorsize)) {
error("bytenr not sectorsize aligned: %llu",
(unsigned long long)bytenr);
error("bytenr not sectorsize aligned: %llu", bytenr);
return -EINVAL;
}
if (len != round_down(len, root->fs_info->sectorsize)) {
error("length not sectorsize aligned: %llu",
(unsigned long long)len);
error("length not sectorsize aligned: %llu", len);
return -EINVAL;
}
len = min_t(u64, len, BTRFS_MAX_EXTENT_SIZE);
@ -318,8 +315,7 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
}
if (len != round_down(len, root->fs_info->sectorsize)) {
error("remaining length not sectorsize aligned: %llu",
(unsigned long long)len);
error("remaining length not sectorsize aligned: %llu", len);
return -EINVAL;
}
ret = btrfs_record_file_extent(trans, root, ino, inode, bytenr,

View File

@ -695,8 +695,7 @@ static int flush_pending(struct metadump_struct *md, int done)
if (ret < size) {
free(async->buffer);
free(async);
error("unable to read superblock at %llu: %m",
(unsigned long long)start);
error("unable to read superblock at %llu: %m", start);
return -errno;
}
size = 0;
@ -711,8 +710,7 @@ static int flush_pending(struct metadump_struct *md, int done)
if (!extent_buffer_uptodate(eb)) {
free(async->buffer);
free(async);
error("unable to read metadata block %llu",
(unsigned long long)start);
error("unable to read metadata block %llu", start);
return -EIO;
}
copy_buffer(md, async->buffer + offset, eb);
@ -976,7 +974,7 @@ static int copy_from_extent_tree(struct metadump_struct *metadump,
if (num_bytes == 0) {
error("extent length 0 at bytenr %llu key type %d",
(unsigned long long)bytenr, key.type);
bytenr, key.type);
ret = -EIO;
break;
}
@ -996,7 +994,7 @@ static int copy_from_extent_tree(struct metadump_struct *metadump,
is_data);
if (ret) {
error("unable to add block %llu: %d",
(unsigned long long)bytenr, ret);
bytenr, ret);
break;
}
}
@ -1961,8 +1959,7 @@ static int read_chunk_block(struct mdrestore_struct *mdres, u8 *buffer,
if (btrfs_header_bytenr(eb) != bytenr) {
error(
"eb bytenr does not match found bytenr: %llu != %llu",
(unsigned long long)btrfs_header_bytenr(eb),
(unsigned long long)bytenr);
btrfs_header_bytenr(eb), bytenr);
ret = -EUCLEAN;
break;
}
@ -1977,8 +1974,7 @@ static int read_chunk_block(struct mdrestore_struct *mdres, u8 *buffer,
}
if (btrfs_header_owner(eb) != BTRFS_CHUNK_TREE_OBJECTID) {
error("wrong eb %llu owner %llu",
(unsigned long long)bytenr,
(unsigned long long)btrfs_header_owner(eb));
bytenr, btrfs_header_owner(eb));
ret = -EUCLEAN;
break;
}
@ -2970,9 +2966,7 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info,
devid = btrfs_device_id(leaf, dev_item);
if (devid != cur_devid) {
error("devid mismatch: %llu != %llu",
(unsigned long long)devid,
(unsigned long long)cur_devid);
error("devid mismatch: %llu != %llu", devid, cur_devid);
ret = -EIO;
goto out;
}
@ -3083,8 +3077,7 @@ int BOX_MAIN(image)(int argc, char *argv[])
num_threads = arg_strtou64(optarg);
if (num_threads > MAX_WORKER_THREADS) {
error("number of threads out of range: %llu > %d",
(unsigned long long)num_threads,
MAX_WORKER_THREADS);
num_threads, MAX_WORKER_THREADS);
return 1;
}
break;
@ -3092,7 +3085,7 @@ int BOX_MAIN(image)(int argc, char *argv[])
compress_level = arg_strtou64(optarg);
if (compress_level > 9) {
error("compression level out of range: %llu",
(unsigned long long)compress_level);
compress_level);
return 1;
}
break;

View File

@ -514,16 +514,14 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
if (cfg->blocks[blk] < first_free) {
error("block[%d] below first free: %llu < %llu",
i, (unsigned long long)cfg->blocks[blk],
(unsigned long long)first_free);
i, cfg->blocks[blk], first_free);
ret = -EINVAL;
goto out;
}
if (i > 0 && cfg->blocks[blk] < cfg->blocks[blocks[i - 1]]) {
error("blocks %d and %d in reverse order: %llu < %llu",
blk, blocks[i - 1],
(unsigned long long)cfg->blocks[blk],
(unsigned long long)cfg->blocks[blocks[i - 1]]);
cfg->blocks[blk], cfg->blocks[blocks[i - 1]]);
ret = -EINVAL;
goto out;
}

View File

@ -359,8 +359,7 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans,
(BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_DATA)) {
allocation->mixed += chunk_size;
} else {
error("unrecognized profile type: 0x%llx",
(unsigned long long)type);
error("unrecognized profile type: 0x%llx", type);
ret = -EINVAL;
}
@ -1502,8 +1501,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
dev_block_count = prepare_ctx[0].dev_block_count;
if (block_count && block_count > dev_block_count) {
error("%s is smaller than requested size, expected %llu, found %llu",
file, (unsigned long long)block_count,
(unsigned long long)dev_block_count);
file, block_count, dev_block_count);
goto error;
}
@ -1511,7 +1509,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
system_group_size = (opt_zoned ? zone_size(file) : BTRFS_MKFS_SYSTEM_GROUP_SIZE);
if (dev_block_count < system_group_size) {
error("device is too small to make filesystem, must be at least %llu",
(unsigned long long)system_group_size);
system_group_size);
goto error;
}
@ -1643,8 +1641,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
device = container_of(fs_info->fs_devices->devices.next,
struct btrfs_device, dev_list);
printf("adding device %s id %llu\n", file,
(unsigned long long)device->devid);
printf("adding device %s id %llu\n", file, device->devid);
}
}

View File

@ -343,8 +343,7 @@ static int add_file_items(struct btrfs_trans_handle *trans,
ret_read = pread64(fd, buffer, st->st_size, bytes_read);
if (ret_read == -1) {
error("cannot read %s at offset %llu length %llu: %m",
path_name, (unsigned long long)bytes_read,
(unsigned long long)st->st_size);
path_name, bytes_read, (unsigned long long)st->st_size);
free(buffer);
goto end;
}
@ -390,10 +389,8 @@ again:
ret_read = pread64(fd, eb->data, sectorsize, file_pos +
bytes_read);
if (ret_read == -1) {
error("cannot read %s at offset %llu length %llu: %m",
path_name,
(unsigned long long)file_pos + bytes_read,
(unsigned long long)sectorsize);
error("cannot read %s at offset %llu length %u: %m",
path_name, file_pos + bytes_read, sectorsize);
goto end;
}