From: David Sterba <dsterba@suse.cz>
To: Andrey Abramov <st5pub@yandex.ru>
Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Fix -Wunused-but-set-variable warnings
Date: Mon, 3 Jun 2019 14:21:52 +0200 [thread overview]
Message-ID: <20190603122152.GM15290@twin.jikos.cz> (raw)
In-Reply-To: <20190531195349.31129-1-st5pub@yandex.ru>
On Fri, May 31, 2019 at 10:53:49PM +0300, Andrey Abramov wrote:
> Fix -Wunused-but-set-variable warnings in raid56.c and sysfs.c files
Please ignore the warnings for now. The RAID56 needs more cleanups than
that an the sysfs part needs to be reworked. The stale code comes from
e410e34fad913dd568ec28d2a9949694324c14db that reverted
14e46e04958df740c6c6a94849f176159a333f13.
> Signed-off-by: Andrey Abramov <st5pub@yandex.ru>
> ---
> fs/btrfs/raid56.c | 32 +++++++++++---------------------
> fs/btrfs/sysfs.c | 5 +----
> 2 files changed, 12 insertions(+), 25 deletions(-)
>
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index f3d0576dd327..4ab29eacfdf3 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -1182,22 +1182,17 @@ 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;
> + int is_q_stripe = 0;
> struct bio_list bio_list;
> struct bio *bio;
> int ret;
>
> 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;
> - q_stripe = rbio->real_stripes - 1;
> - } else {
> + if (rbio->real_stripes - rbio->nr_data == 2)
> + is_q_stripe = 1;
> + else if (rbio->real_stripes - rbio->nr_data != 1)
> BUG();
> - }
The original code is better structured, enumerates the expected cases
and leaves a catch-all branch.
>
> /* at this point we either have a full stripe,
> * or we've read the full stripe from the drive.
> @@ -1241,7 +1236,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
> SetPageUptodate(p);
> pointers[stripe++] = kmap(p);
>
> - if (q_stripe != -1) {
> + if (is_q_stripe) {
>
> /*
> * raid6, add the qstripe and call the
> @@ -2340,8 +2335,7 @@ 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;
To get rid of the warning, perhaps just this initialization could be
removed, the rest of the code untouched.
> - int q_stripe = -1;
> + int is_q_stripe = 0;
> struct page *p_page = NULL;
> struct page *q_page = NULL;
> struct bio_list bio_list;
prev parent reply other threads:[~2019-06-03 12:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 19:53 Andrey Abramov
2019-05-31 20:05 ` Joe Perches
2019-05-31 20:31 ` Andrey Abramov
2019-05-31 20:38 ` Joe Perches
2019-06-03 12:21 ` David Sterba [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190603122152.GM15290@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=st5pub@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®