diff mbox series

fs/btrfs/raid56.c: remove set but not used variables 'p_stripe'

Message ID 1566447421-16137-1-git-send-email-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series fs/btrfs/raid56.c: remove set but not used variables 'p_stripe' | expand

Commit Message

Zheng Bin Aug. 22, 2019, 4:17 a.m. UTC
fs/btrfs/raid56.c: In function finish_rmw:
fs/btrfs/raid56.c:1185:6: warning: variable p_stripe set but not used [-Wunused-but-set-variable]
fs/btrfs/raid56.c: In function finish_parity_scrub:
fs/btrfs/raid56.c:2343:6: warning: variable p_stripe set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/btrfs/raid56.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

--
2.7.4

Comments

Nikolay Borisov Aug. 22, 2019, 6:56 a.m. UTC | #1
On 22.08.19 г. 7:17 ч., zhengbin wrote:
> fs/btrfs/raid56.c: In function finish_rmw:
> fs/btrfs/raid56.c:1185:6: warning: variable p_stripe set but not used [-Wunused-but-set-variable]
> fs/btrfs/raid56.c: In function finish_parity_scrub:
> fs/btrfs/raid56.c:2343:6: warning: variable p_stripe set but not used [-Wunused-but-set-variable]
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>

Have you tested this patch on a RAID5/6 configuration? WHy do I think
that for the raid 5 case (if (rbio->real_stripes - rbio->nr_data == 1))
we'll now go into the else clause and BUG, despite the variable not
being used.

> ---
>  fs/btrfs/raid56.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index f3d0576..2603f99 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -1182,7 +1182,6 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
>  	int nr_data = rbio->nr_data;
>  	int stripe;
>  	int pagenr;
> -	int p_stripe = -1;
>  	int q_stripe = -1;
>  	struct bio_list bio_list;
>  	struct bio *bio;
> @@ -1190,14 +1189,10 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
> 
>  	bio_list_init(&bio_list);
> 
> -	if (rbio->real_stripes - rbio->nr_data == 1) {
> -		p_stripe = rbio->real_stripes - 1;
> -	} else if (rbio->real_stripes - rbio->nr_data == 2) {
> -		p_stripe = rbio->real_stripes - 2;
> +	if (rbio->real_stripes - rbio->nr_data == 2)
>  		q_stripe = rbio->real_stripes - 1;
> -	} else {
> +	else if (rbio->real_stripes - rbio->nr_data != 1)
>  		BUG();
> -	}
> 
>  	/* at this point we either have a full stripe,
>  	 * or we've read the full stripe from the drive.
> @@ -2340,7 +2335,6 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
>  	int nr_data = rbio->nr_data;
>  	int stripe;
>  	int pagenr;
> -	int p_stripe = -1;
>  	int q_stripe = -1;
>  	struct page *p_page = NULL;
>  	struct page *q_page = NULL;
> @@ -2351,14 +2345,10 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
> 
>  	bio_list_init(&bio_list);
> 
> -	if (rbio->real_stripes - rbio->nr_data == 1) {
> -		p_stripe = rbio->real_stripes - 1;
> -	} else if (rbio->real_stripes - rbio->nr_data == 2) {
> -		p_stripe = rbio->real_stripes - 2;
> +	if (rbio->real_stripes - rbio->nr_data == 2)
>  		q_stripe = rbio->real_stripes - 1;
> -	} else {
> +	else if (rbio->real_stripes - rbio->nr_data != 1)
>  		BUG();
> -	}
> 
>  	if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) {
>  		is_replace = 1;
> --
> 2.7.4
> 
>
diff mbox series

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index f3d0576..2603f99 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1182,7 +1182,6 @@  static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
 	int nr_data = rbio->nr_data;
 	int stripe;
 	int pagenr;
-	int p_stripe = -1;
 	int q_stripe = -1;
 	struct bio_list bio_list;
 	struct bio *bio;
@@ -1190,14 +1189,10 @@  static noinline void finish_rmw(struct btrfs_raid_bio *rbio)

 	bio_list_init(&bio_list);

-	if (rbio->real_stripes - rbio->nr_data == 1) {
-		p_stripe = rbio->real_stripes - 1;
-	} else if (rbio->real_stripes - rbio->nr_data == 2) {
-		p_stripe = rbio->real_stripes - 2;
+	if (rbio->real_stripes - rbio->nr_data == 2)
 		q_stripe = rbio->real_stripes - 1;
-	} else {
+	else if (rbio->real_stripes - rbio->nr_data != 1)
 		BUG();
-	}

 	/* at this point we either have a full stripe,
 	 * or we've read the full stripe from the drive.
@@ -2340,7 +2335,6 @@  static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
 	int nr_data = rbio->nr_data;
 	int stripe;
 	int pagenr;
-	int p_stripe = -1;
 	int q_stripe = -1;
 	struct page *p_page = NULL;
 	struct page *q_page = NULL;
@@ -2351,14 +2345,10 @@  static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,

 	bio_list_init(&bio_list);

-	if (rbio->real_stripes - rbio->nr_data == 1) {
-		p_stripe = rbio->real_stripes - 1;
-	} else if (rbio->real_stripes - rbio->nr_data == 2) {
-		p_stripe = rbio->real_stripes - 2;
+	if (rbio->real_stripes - rbio->nr_data == 2)
 		q_stripe = rbio->real_stripes - 1;
-	} else {
+	else if (rbio->real_stripes - rbio->nr_data != 1)
 		BUG();
-	}

 	if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) {
 		is_replace = 1;