Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4384155ybi; Mon, 3 Jun 2019 09:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNRWesQejqVhmO6xw5oxIXIFxFef6ZSs9Wpc+vvzPd3wiccKnRjdnlMgnPLx0deshNKoc5 X-Received: by 2002:a63:788a:: with SMTP id t132mr30290817pgc.52.1559581134121; Mon, 03 Jun 2019 09:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559581134; cv=none; d=google.com; s=arc-20160816; b=h8YedNY18H2lO54KQ4F+N7aZBVIZaZ78PPcJPROpSik6c6Ql0AaZZkOTSVk4TlHBP6 Wdz1o+73nabqhbtnhz4d858S6xKvCyFxD7IX3LY2fpizI3b1/TPh7NxLokUShFoTiiqY MWLcLVgisNq2qhZJR1vqqXCDa9K/EMiXHIKvR+QeujXBzikrem1IgCSUmD4hDjBMrVoA +qiLiEvY+8tShFJdiQK/xUTcu06YdzOkUvPZABCNxO1TZyyZYSboQh3dIK2h9Uz5G7N3 pUyFEA76vSJW7vM5w06VRGvDR/3ZetOj4BS0WHNb+QQASIk5n8CP2o2nKTtDF5LfZ5ye bn2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date; bh=bROdzaNKgAEVhPEiVEPIV86BgmkzXqSS8oGM8rimWxY=; b=x18GAfQ5OufT6NACT0q1LPpgo+JtiWo7H4vD6fE5VjV6EDysnd+PhVDv36/F6e/BgZ puHrYMK3dAfdUQe3uSOiup3G4V8iiygQuLLPhmf1L0McRxgsGNUrW3VT03N2eHNN4mbO Jadn5EFS8WQWfkErcsJPRqaGHItNPvhi9AidBlf80UHO7JTRKuRCgIZfjtZzCLUUAV2h TWNSsB0OSvBZNej3SARbtEOecRiqlzsXeA2n/iPis7/lOtRDSMtVa7YFeeatn4xOP2/V o5N7EddsFOxouy1591wu0mGEGDM4xhu/xctyX4MRL4WJHilu2n3wsNP9U+ZUb9FETvmL CddA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az8si19163874plb.219.2019.06.03.09.58.38; Mon, 03 Jun 2019 09:58:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbfFCMVF (ORCPT + 99 others); Mon, 3 Jun 2019 08:21:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:56724 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726342AbfFCMVF (ORCPT ); Mon, 3 Jun 2019 08:21:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 03AD1AE4B; Mon, 3 Jun 2019 12:21:03 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 12668DA85E; Mon, 3 Jun 2019 14:21:54 +0200 (CEST) Date: Mon, 3 Jun 2019 14:21:52 +0200 From: David Sterba To: Andrey Abramov 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 Message-ID: <20190603122152.GM15290@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Andrey Abramov , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190531195349.31129-1-st5pub@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531195349.31129-1-st5pub@yandex.ru> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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;