btrfs-progs: fix set but not used variables

[WARNING]
Clang 15.0.7 warns about several unused variables:

  kernel-shared/zoned.c:829:6: warning: variable 'num_sequential' set but not used [-Wunused-but-set-variable]
          u32 num_sequential = 0, num_conventional = 0;
              ^
  cmds/scrub.c:1174:6: warning: variable 'n_skip' set but not used [-Wunused-but-set-variable]
          int n_skip = 0;
              ^
  mkfs/main.c:493:6: warning: variable 'total_block_count' set but not used [-Wunused-but-set-variable]
          u64 total_block_count = 0;
              ^
  image/main.c:2246:6: warning: variable 'bytenr' set but not used [-Wunused-but-set-variable]
          u64 bytenr = 0;
              ^

[CAUSE]
Most of them are just straightforward set but not used variables.

The only exception is total_block_count, which has commented out code
relying on it.

[FIX]
Just remove those variables, and for @total_block_count, also remove the
comments.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2023-01-27 13:41:18 +08:00 committed by David Sterba
parent c3a41e5d4c
commit f914949b1a
4 changed files with 2 additions and 13 deletions

View File

@ -1171,7 +1171,6 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,
int ioprio_class = IOPRIO_CLASS_IDLE;
int ioprio_classdata = 0;
int n_start = 0;
int n_skip = 0;
int n_resume = 0;
struct btrfs_ioctl_fs_info_args fi_args;
struct btrfs_ioctl_dev_info_args *di_args = NULL;
@ -1337,7 +1336,6 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,
sp[i].scrub_args.start = last_scrub->p.last_physical;
sp[i].resumed = last_scrub;
} else if (resume) {
++n_skip;
sp[i].skip = 1;
sp[i].resumed = last_scrub;
continue;

View File

@ -2244,7 +2244,6 @@ static int build_chunk_tree(struct mdrestore_struct *mdres,
struct meta_cluster_header *header;
struct meta_cluster_item *item = NULL;
u32 i, nritems;
u64 bytenr = 0;
u8 *buffer;
int ret;
@ -2266,7 +2265,6 @@ static int build_chunk_tree(struct mdrestore_struct *mdres,
return -EIO;
}
bytenr += IMAGE_BLOCK_SIZE;
mdres->compress_method = header->compress;
nritems = le32_to_cpu(header->nritems);
for (i = 0; i < nritems; i++) {
@ -2274,7 +2272,6 @@ static int build_chunk_tree(struct mdrestore_struct *mdres,
if (le64_to_cpu(item->bytenr) == BTRFS_SUPER_INFO_OFFSET)
break;
bytenr += le32_to_cpu(item->size);
if (fseek(mdres->in, le32_to_cpu(item->size), SEEK_CUR)) {
error("seek failed: %m");
return -EIO;

View File

@ -826,7 +826,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
int i;
u64 *alloc_offsets = NULL;
u64 last_alloc = 0;
u32 num_sequential = 0, num_conventional = 0;
u32 num_conventional = 0;
if (!btrfs_is_zoned(fs_info))
return 0;
@ -870,9 +870,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
}
is_sequential = btrfs_dev_is_sequential(device, physical);
if (is_sequential)
num_sequential++;
else
if (!is_sequential)
num_conventional++;
if (!is_sequential) {

View File

@ -490,7 +490,6 @@ static void list_all_devices(struct btrfs_root *root)
struct btrfs_fs_devices *fs_devices;
struct btrfs_device *device;
int number_of_devices = 0;
u64 total_block_count = 0;
fs_devices = root->fs_info->fs_devices;
@ -500,8 +499,6 @@ static void list_all_devices(struct btrfs_root *root)
list_sort(NULL, &fs_devices->devices, _cmp_device_by_id);
printf("Number of devices: %d\n", number_of_devices);
/* printf("Total devices size: %10s\n", */
/* pretty_size(total_block_count)); */
printf("Devices:\n");
printf(" ID SIZE PATH\n");
list_for_each_entry(device, &fs_devices->devices, dev_list) {
@ -509,7 +506,6 @@ static void list_all_devices(struct btrfs_root *root)
device->devid,
pretty_size(device->total_bytes),
device->name);
total_block_count += device->total_bytes;
}
printf("\n");