Commit d2715d1d authored by David Sterba's avatar David Sterba

btrfs: use for-local variables that shadow function variables

We've started to use for-loop local variables and in a few places this
shadows a function variable. Convert a few cases reported by 'make W=2'.
If applicable also change the style to post-increment, that's the
preferred one.
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 91629e6d
...@@ -3222,7 +3222,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3222,7 +3222,6 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
struct btrfs_qgroup_inherit *inherit) struct btrfs_qgroup_inherit *inherit)
{ {
int ret = 0; int ret = 0;
int i;
u64 *i_qgroups; u64 *i_qgroups;
bool committing = false; bool committing = false;
struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_fs_info *fs_info = trans->fs_info;
...@@ -3279,7 +3278,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3279,7 +3278,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
i_qgroups = (u64 *)(inherit + 1); i_qgroups = (u64 *)(inherit + 1);
nums = inherit->num_qgroups + 2 * inherit->num_ref_copies + nums = inherit->num_qgroups + 2 * inherit->num_ref_copies +
2 * inherit->num_excl_copies; 2 * inherit->num_excl_copies;
for (i = 0; i < nums; ++i) { for (int i = 0; i < nums; i++) {
srcgroup = find_qgroup_rb(fs_info, *i_qgroups); srcgroup = find_qgroup_rb(fs_info, *i_qgroups);
/* /*
...@@ -3306,7 +3305,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3306,7 +3305,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
*/ */
if (inherit) { if (inherit) {
i_qgroups = (u64 *)(inherit + 1); i_qgroups = (u64 *)(inherit + 1);
for (i = 0; i < inherit->num_qgroups; ++i, ++i_qgroups) { for (int i = 0; i < inherit->num_qgroups; i++, i_qgroups++) {
if (*i_qgroups == 0) if (*i_qgroups == 0)
continue; continue;
ret = add_qgroup_relation_item(trans, objectid, ret = add_qgroup_relation_item(trans, objectid,
...@@ -3392,7 +3391,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3392,7 +3391,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
goto unlock; goto unlock;
i_qgroups = (u64 *)(inherit + 1); i_qgroups = (u64 *)(inherit + 1);
for (i = 0; i < inherit->num_qgroups; ++i) { for (int i = 0; i < inherit->num_qgroups; i++) {
if (*i_qgroups) { if (*i_qgroups) {
ret = add_relation_rb(fs_info, qlist_prealloc[i], objectid, ret = add_relation_rb(fs_info, qlist_prealloc[i], objectid,
*i_qgroups); *i_qgroups);
...@@ -3412,7 +3411,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3412,7 +3411,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
++i_qgroups; ++i_qgroups;
} }
for (i = 0; i < inherit->num_ref_copies; ++i, i_qgroups += 2) { for (int i = 0; i < inherit->num_ref_copies; i++, i_qgroups += 2) {
struct btrfs_qgroup *src; struct btrfs_qgroup *src;
struct btrfs_qgroup *dst; struct btrfs_qgroup *dst;
...@@ -3433,7 +3432,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, ...@@ -3433,7 +3432,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
/* Manually tweaking numbers certainly needs a rescan */ /* Manually tweaking numbers certainly needs a rescan */
need_rescan = true; need_rescan = true;
} }
for (i = 0; i < inherit->num_excl_copies; ++i, i_qgroups += 2) { for (int i = 0; i < inherit->num_excl_copies; i++, i_qgroups += 2) {
struct btrfs_qgroup *src; struct btrfs_qgroup *src;
struct btrfs_qgroup *dst; struct btrfs_qgroup *dst;
......
...@@ -5626,8 +5626,6 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans, ...@@ -5626,8 +5626,6 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans,
u64 start = ctl->start; u64 start = ctl->start;
u64 type = ctl->type; u64 type = ctl->type;
int ret; int ret;
int i;
int j;
map = btrfs_alloc_chunk_map(ctl->num_stripes, GFP_NOFS); map = btrfs_alloc_chunk_map(ctl->num_stripes, GFP_NOFS);
if (!map) if (!map)
...@@ -5642,8 +5640,8 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans, ...@@ -5642,8 +5640,8 @@ static struct btrfs_block_group *create_chunk(struct btrfs_trans_handle *trans,
map->sub_stripes = ctl->sub_stripes; map->sub_stripes = ctl->sub_stripes;
map->num_stripes = ctl->num_stripes; map->num_stripes = ctl->num_stripes;
for (i = 0; i < ctl->ndevs; ++i) { for (int i = 0; i < ctl->ndevs; i++) {
for (j = 0; j < ctl->dev_stripes; ++j) { for (int j = 0; j < ctl->dev_stripes; j++) {
int s = i * ctl->dev_stripes + j; int s = i * ctl->dev_stripes + j;
map->stripes[s].dev = devices_info[i].dev; map->stripes[s].dev = devices_info[i].dev;
map->stripes[s].physical = devices_info[i].dev_offset + map->stripes[s].physical = devices_info[i].dev_offset +
...@@ -6621,7 +6619,6 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6621,7 +6619,6 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
struct btrfs_chunk_map *map; struct btrfs_chunk_map *map;
struct btrfs_io_geometry io_geom = { 0 }; struct btrfs_io_geometry io_geom = { 0 };
u64 map_offset; u64 map_offset;
int i;
int ret = 0; int ret = 0;
int num_copies; int num_copies;
struct btrfs_io_context *bioc = NULL; struct btrfs_io_context *bioc = NULL;
...@@ -6767,7 +6764,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op, ...@@ -6767,7 +6764,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
* For all other non-RAID56 profiles, just copy the target * For all other non-RAID56 profiles, just copy the target
* stripe into the bioc. * stripe into the bioc.
*/ */
for (i = 0; i < io_geom.num_stripes; i++) { for (int i = 0; i < io_geom.num_stripes; i++) {
ret = set_io_stripe(fs_info, logical, length, ret = set_io_stripe(fs_info, logical, length,
&bioc->stripes[i], map, &io_geom); &bioc->stripes[i], map, &io_geom);
if (ret < 0) if (ret < 0)
......
...@@ -87,9 +87,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones, ...@@ -87,9 +87,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
bool empty[BTRFS_NR_SB_LOG_ZONES]; bool empty[BTRFS_NR_SB_LOG_ZONES];
bool full[BTRFS_NR_SB_LOG_ZONES]; bool full[BTRFS_NR_SB_LOG_ZONES];
sector_t sector; sector_t sector;
int i;
for (i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) { for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
ASSERT(zones[i].type != BLK_ZONE_TYPE_CONVENTIONAL); ASSERT(zones[i].type != BLK_ZONE_TYPE_CONVENTIONAL);
empty[i] = (zones[i].cond == BLK_ZONE_COND_EMPTY); empty[i] = (zones[i].cond == BLK_ZONE_COND_EMPTY);
full[i] = sb_zone_is_full(&zones[i]); full[i] = sb_zone_is_full(&zones[i]);
...@@ -121,9 +120,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones, ...@@ -121,9 +120,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
struct address_space *mapping = bdev->bd_mapping; struct address_space *mapping = bdev->bd_mapping;
struct page *page[BTRFS_NR_SB_LOG_ZONES]; struct page *page[BTRFS_NR_SB_LOG_ZONES];
struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES]; struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES];
int i;
for (i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) { for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT; u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) - u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
BTRFS_SUPER_INFO_SIZE; BTRFS_SUPER_INFO_SIZE;
...@@ -144,7 +142,7 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones, ...@@ -144,7 +142,7 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
else else
sector = zones[0].start; sector = zones[0].start;
for (i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) for (int i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++)
btrfs_release_disk_super(super[i]); btrfs_release_disk_super(super[i]);
} else if (!full[0] && (empty[1] || full[1])) { } else if (!full[0] && (empty[1] || full[1])) {
sector = zones[0].wp; sector = zones[0].wp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment