Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp657783rdb; Thu, 30 Nov 2023 14:58:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpZQ/3F/PsclcamFJNHzHVF1FswCSdBWqt8SrJeZco8bJFxQsuzI/U2lQQGUpAiXdOw/39 X-Received: by 2002:a17:902:e54b:b0:1cf:9ea1:ff93 with SMTP id n11-20020a170902e54b00b001cf9ea1ff93mr31682951plf.43.1701385086915; Thu, 30 Nov 2023 14:58:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701385086; cv=none; d=google.com; s=arc-20160816; b=EHk0p+HSwodv6DT3p7tiD0ScD6xr81TWFLkhax6REddcEnGIrgpxs0ogRzuKryhmcR SS/7aJ6hn3gnMgSbuk1VTTg/qrkSLtQ1YbRiGVZ7eICPu6GoeKqZ0kpu0G20r80jHVSG 2ue1Yo2WjjAoeNkm9dc1H4uQ1nsUFPZd+BUhbPHltcStYWU5/+ufIZXCNhZJb0WMC+rO BwEMQah3HVMu+WNvBiRk3HdDtVgnqcUHlpe53OrVehGLF7uFCkPyQbgaTuGVCSX+trxO s/93EIu3EWRdYwbblUrwte7xir3DcaypMvFNb6x1NHUFhVLnBtR++5fQCiLvK2kr44fw x9og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date; bh=Dm03XNWiczjzTRCjjpq8tOQmk3MldGD4jbSi0webXqY=; fh=IZM8Nps+XybKj9/Aehgdx2Qx95Z/Fg+3AtGie8qzyoM=; b=srCDDcu4ROgNTnlDxw6Iz4YeDeZrG8uKhTUMFg/sVSnGnNwh+y4i/pg640p1/wuINF lFvcETk8O8FjJBNSjNt9vIQ+yDO96pnTy5JFHyBEfJEIIJrgRLTFcTLmKQGWrMhctn0q O8UQTtu6i04TUd9TpNyeuN3tOxav7yKoEiK3CD1MMsp28vpIp06YUOLjXFCVyAqgUDCy 8LqZi1NxBxKHBZm5V/cnHklQR02pkAhEDUWqtbdI0S2kK6kz1hxXWnzjTq5YmX7NruK/ AFVGbSNyDh2WqultFyVN1O7qMIwM7x3Yak7xadRmez8XNvesjHpUfkWipdn7+ZiBx3o6 eWGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b2-20020a170902b60200b001cfd360a185si1983328pls.100.2023.11.30.14.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 14:58:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 434668024075; Thu, 30 Nov 2023 14:58:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377201AbjK3W5s (ORCPT + 99 others); Thu, 30 Nov 2023 17:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377192AbjK3W5q (ORCPT ); Thu, 30 Nov 2023 17:57:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C4E194; Thu, 30 Nov 2023 14:57:52 -0800 (PST) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 767661FD11; Thu, 30 Nov 2023 22:57:51 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 4FDDE138E5; Thu, 30 Nov 2023 22:57:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id O5H+Em8TaWXDYAAAn2gu4w (envelope-from ); Thu, 30 Nov 2023 22:57:51 +0000 Date: Thu, 30 Nov 2023 23:50:33 +0100 From: David Sterba To: Colin Ian King Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] btrfs: remove shadowed declaration of variable i in for-loops Message-ID: <20231130225033.GV18929@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <20231130150811.2208562-1-colin.i.king@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231130150811.2208562-1-colin.i.king@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spamd-Bar: +++++++++++++ X-Spam-Score: 13.01 X-Rspamd-Server: rspamd1 Authentication-Results: smtp-out2.suse.de; dkim=none; spf=softfail (smtp-out2.suse.de: 2a07:de40:b281:104:10:150:64:98 is neither permitted nor denied by domain of dsterba@suse.cz) smtp.mailfrom=dsterba@suse.cz; dmarc=none X-Rspamd-Queue-Id: 767661FD11 X-Spamd-Result: default: False [13.01 / 50.00]; HAS_REPLYTO(0.30)[dsterba@suse.cz]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLYTO_ADDR_EQ_FROM(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all]; DMARC_NA(1.20)[suse.cz]; RCVD_COUNT_THREE(0.00)[3]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.18)[-0.920]; RCPT_COUNT_SEVEN(0.00)[7]; NEURAL_SPAM_LONG(3.50)[1.000]; FREEMAIL_TO(0.00)[gmail.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Status: No, score=1.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,TVD_SUBJ_WIPE_DEBT, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 30 Nov 2023 14:58:04 -0800 (PST) X-Spam-Level: * On Thu, Nov 30, 2023 at 03:08:11PM +0000, Colin Ian King wrote: > The variable i is declared at the start of function btrfs_qgroup_inherit > however there are two for-loops that redeclare the variable using a C99 > declaration, causes name shadowing. I believe there is no need for this > local scoping of i in the loop, so replace the declaration in the loops > with assignments. > > Cleans up clang scan build warnings: > > fs/btrfs/qgroup.c:3194:12: warning: declaration shadows a local variable [-Wshadow] > 3194 | for (int i = 0; i < inherit->num_qgroups; i++) { > | ^ > fs/btrfs/qgroup.c:3089:6: note: previous declaration is here > 3089 | int i; > | ^ > fs/btrfs/qgroup.c:3321:12: warning: declaration shadows a local variable [-Wshadow] > 3321 | for (int i = 0; i < inherit->num_qgroups; i++) > | ^ > fs/btrfs/qgroup.c:3089:6: note: previous declaration is here > 3089 | int i; > | ^ > > Signed-off-by: Colin Ian King > --- > fs/btrfs/qgroup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index ce446d9d7f23..b1f93dbf468c 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -3191,7 +3191,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, > ret = -ENOMEM; > goto out; > } > - for (int i = 0; i < inherit->num_qgroups; i++) { > + for (i = 0; i < inherit->num_qgroups; i++) { We want to use the for(...) local definitions, so this should change the function scope 'i'.