From f914949b1a10fd256288d874f51931793f79704a Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 27 Jan 2023 13:41:18 +0800 Subject: [PATCH] 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 Signed-off-by: David Sterba --- cmds/scrub.c | 2 -- image/main.c | 3 --- kernel-shared/zoned.c | 6 ++---- mkfs/main.c | 4 ---- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/cmds/scrub.c b/cmds/scrub.c index 782a1310..65c7c5b6 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -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; diff --git a/image/main.c b/image/main.c index 6f1670cb..65aa3b30 100644 --- a/image/main.c +++ b/image/main.c @@ -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; diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c index a79fc6a5..f06ee243 100644 --- a/kernel-shared/zoned.c +++ b/kernel-shared/zoned.c @@ -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) { diff --git a/mkfs/main.c b/mkfs/main.c index 9f106e33..341ba408 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -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");