Message ID | 20231111204528.339603-1-colin.i.king@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp413275vqg; Sat, 11 Nov 2023 12:49:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcWjhmESZMzN4Lvh+AHCkvC2jdt+goIfa0a78mi7dsmEzvaFHSsDdMzb6SEe8NHjMLH2ud X-Received: by 2002:a05:6808:3a2:b0:3ad:fb3a:4b6 with SMTP id n2-20020a05680803a200b003adfb3a04b6mr3769994oie.41.1699735752133; Sat, 11 Nov 2023 12:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699735752; cv=none; d=google.com; s=arc-20160816; b=Venxp8E3Y8l5hCj2FTR5In4YUzB8ELUf1SKHSQ1+rttrpL9IbYGaItSbaFueRpSFrw CqcE13MVPeLbvgLKija3FffmkTA4YlOFyTvTRJXGnirZPl3EPSQInAv+cNxBLuEw2AHt KlzAhQgmtAzgNefwk7Qe6w9MELK+Uvi+QzklA9Xm/P87zypXMpOQ0mUQOABJxP8DxQOv reMcd1fGSnAD2vvlWGrvYG8h1emMoSI4kMw7MM0MUjFJM7BKPBhW+b3Dom6zytlNWEfI NxOSQGGcyGMBe++iQaOajWHO2uaXlFCpC/AjELIgiwx97HxB5ft4oVkyL/InqVnCXMNW XMLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1GkldlTDmPluuvc25beXnNrRPdT3yBfUXiF7PvmZBoU=; fh=XG4WW3CNAL509GDoc/W3Ryl++WqlrKFHTUxG5J6uH4c=; b=D2KacuJzxYrcUVZNVQrc9JinXEiYDT9iHCfACrD9mcWl4K6L4lB56yUXd4RQHm5Ro6 6N1jfJEWfngfCVD9yu6lkaPSwPPw5QgH8Dm+nnkXCHiOGo0phFT8BaWK3F+YGAg+1DS9 balgNVMdTA3UpBphE6Fh9colX/6ahsDCx4yjkgiylJG5F68xAqtyVXLLdEFSliRDu/O0 AbF06eJwNd9vFJkL2ggPiF63UCiLjDnpp6gExxMG1fyx4hc1COgI2cTe6rgMQEP86w0Z zhe1PrDtOLM9L9HwjXCS+jWwHTAwtXz+md86LdsyREYQUicM3dJwAEtUBXNsarbzKDrq Bk0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=igikoE07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j3-20020a056a00174300b006c1222c5eaasi2543675pfc.175.2023.11.11.12.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Nov 2023 12:49:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=igikoE07; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 25CB9809C93A; Sat, 11 Nov 2023 12:49:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjKKUph (ORCPT <rfc822;heyuhang3455@gmail.com> + 29 others); Sat, 11 Nov 2023 15:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbjKKUpg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 11 Nov 2023 15:45:36 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A3122D73; Sat, 11 Nov 2023 12:45:31 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40838915cecso24756385e9.2; Sat, 11 Nov 2023 12:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699735530; x=1700340330; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1GkldlTDmPluuvc25beXnNrRPdT3yBfUXiF7PvmZBoU=; b=igikoE07FWz+f0R7yAYolVossedFUBOmjV37o8cwYHUBDIk/x5Jmq57bzeIIHoPaql LiJUhZACoGZJ4rmCavLpeUR16+Zl9Srye3NbTg/UuxYjKWah4Y6uHatvYMVfDtsKqv/R LvXrnJjId3KndWzozdiznVRe6G+Z0nnGG8PjjI2GjAMZPi8W7cEJiIc2r3Qt+OwyLOBu DgVQtJOBK7ejZ9AFMmGQxeJHFomlrDolKxCxEOnWagDykovKhPa1zwaTzPmQelfDTfRY GTRLGr2JTWbZhCeabS20rNp4kGFBLgmn0nLHkTdu49yatphuRpugZ7I6VfXJ91aSofPA 6h8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699735530; x=1700340330; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1GkldlTDmPluuvc25beXnNrRPdT3yBfUXiF7PvmZBoU=; b=HDQ2SwNidDdR5Zw+urfmcyxv6JtcR+8vPvsmF1GoB785TxhG3TkwMLM13xiHKlbYYh 6QHTZVhAciPeYh6LNdxfHszoxjqpbMo+5/Q6lR8GlVhLjNJh1WZVuA+DkUTTUODLza5B eP9vOE7GZUsSvvZvWwNGPsvyTwgtM0Kd4IQzvFnKDaFoJ4KaAG6DJtRkDCLjU9rdye/9 84yGW6lAMjHJRXohUKbYZ6tIouzjw5s3/ErH3Mwn1nF7X0anafso246IvvMYNm/bR7M1 xa2TzyExCAaByDyqNhFI9/tPP6ctIC6fGnhdaqyuCILSSmJb5flRub1lZmoUkEZ+sEsd /Asg== X-Gm-Message-State: AOJu0YypRnBpjshuyjR5/BG+hxE9X4MOowfakHeIZPwq4TjP4whvC0h3 ujm+Bb2Hs4Rq7NHdhlEju3s= X-Received: by 2002:a05:600c:6022:b0:409:c1e:7fe8 with SMTP id az34-20020a05600c602200b004090c1e7fe8mr2295978wmb.19.1699735529845; Sat, 11 Nov 2023 12:45:29 -0800 (PST) Received: from localhost (cpc154979-craw9-2-0-cust193.16-3.cable.virginm.net. [80.193.200.194]) by smtp.gmail.com with ESMTPSA id q25-20020a7bce99000000b004068e09a70bsm3042688wmj.31.2023.11.11.12.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Nov 2023 12:45:29 -0800 (PST) From: Colin Ian King <colin.i.king@gmail.com> To: Kent Overstreet <kent.overstreet@linux.dev>, Brian Foster <bfoster@redhat.com>, linux-bcachefs@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] bcachefs: remove redundant initialization of variable level Date: Sat, 11 Nov 2023 20:45:28 +0000 Message-Id: <20231111204528.339603-1-colin.i.king@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 11 Nov 2023 12:49:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782302116059797575 X-GMAIL-MSGID: 1782302116059797575 |
Series |
[next] bcachefs: remove redundant initialization of variable level
|
|
Commit Message
Colin Ian King
Nov. 11, 2023, 8:45 p.m. UTC
Variable level is being initialized a value that is never read, the
variable is being re-assigned another value several statements later
on. The initialization is redundant and can be removed. Cleans up
clang scan build warning:
fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level'
during its initialization is never read [deadcode.DeadStores]
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/bcachefs/btree_iter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Sat, Nov 11, 2023 at 08:45:28PM +0000, Colin Ian King wrote: > Variable level is being initialized a value that is never read, the > variable is being re-assigned another value several statements later > on. The initialization is redundant and can be removed. Cleans up > clang scan build warning: > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level' > during its initialization is never read [deadcode.DeadStores] > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> since we're no longer gnu89, we can simply declare the variable when it's first used, like so: diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 96bdf0c6051c..104172f6822b 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1214,8 +1214,6 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, struct btree_path *path, struct bpos new_pos, bool intent, unsigned long ip, int cmp) { - unsigned level = path->level; - bch2_trans_verify_not_in_restart(trans); EBUG_ON(!path->ref); @@ -1231,7 +1229,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, goto out; } - level = btree_path_up_until_good_node(trans, path, cmp); + unsigned level = btree_path_up_until_good_node(trans, path, cmp); if (btree_path_node(path, level)) { struct btree_path_level *l = &path->l[level];
From: Kent Overstreet <kent.overstreet@linux.dev> > Sent: 11 November 2023 21:02 > > Variable level is being initialized a value that is never read, the > > variable is being re-assigned another value several statements later > > on. The initialization is redundant and can be removed. Cleans up > > clang scan build warning: > > > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level' > > during its initialization is never read [deadcode.DeadStores] > > > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > > since we're no longer gnu89, we can simply declare the variable when > it's first used, like so: ugg... I think that is still frowned upon. It makes it very difficult for the average human to find the variable declaration. David > > diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c > index 96bdf0c6051c..104172f6822b 100644 > --- a/fs/bcachefs/btree_iter.c > +++ b/fs/bcachefs/btree_iter.c > @@ -1214,8 +1214,6 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, > struct btree_path *path, struct bpos new_pos, > bool intent, unsigned long ip, int cmp) > { > - unsigned level = path->level; > - > bch2_trans_verify_not_in_restart(trans); > EBUG_ON(!path->ref); > > @@ -1231,7 +1229,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, > goto out; > } > > - level = btree_path_up_until_good_node(trans, path, cmp); > + unsigned level = btree_path_up_until_good_node(trans, path, cmp); > > if (btree_path_node(path, level)) { > struct btree_path_level *l = &path->l[level]; - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Sat, Nov 11, 2023 at 09:19:40PM +0000, David Laight wrote: > From: Kent Overstreet <kent.overstreet@linux.dev> > > Sent: 11 November 2023 21:02 > > > Variable level is being initialized a value that is never read, the > > > variable is being re-assigned another value several statements later > > > on. The initialization is redundant and can be removed. Cleans up > > > clang scan build warning: > > > > > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level' > > > during its initialization is never read [deadcode.DeadStores] > > > > > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > > > > since we're no longer gnu89, we can simply declare the variable when > > it's first used, like so: > > ugg... I think that is still frowned upon. > It makes it very difficult for the average human to find > the variable declaration. No, it's 2023, there's no good reason to be declaring variables before giving them values.
From: Kent Overstreet > Sent: 11 November 2023 23:39 > > On Sat, Nov 11, 2023 at 09:19:40PM +0000, David Laight wrote: > > From: Kent Overstreet <kent.overstreet@linux.dev> > > > Sent: 11 November 2023 21:02 > > > > Variable level is being initialized a value that is never read, the > > > > variable is being re-assigned another value several statements later > > > > on. The initialization is redundant and can be removed. Cleans up > > > > clang scan build warning: > > > > > > > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level' > > > > during its initialization is never read [deadcode.DeadStores] > > > > > > > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > > > > > > since we're no longer gnu89, we can simply declare the variable when > > > it's first used, like so: > > > > ugg... I think that is still frowned upon. > > It makes it very difficult for the average human to find > > the variable declaration. > > No, it's 2023, there's no good reason to be declaring variables before > giving them values. The year has nothing to do with whether it is a good idea. It is epically bad without -Wshadow. (Have you ever played 'stop the declaration' in C++, it isn't fun.) Finding declarations is bad enough when they are at the top of a big block, never mind in the middle of a load of assignments. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On Sun, Nov 12, 2023 at 06:34:59PM +0000, David Laight wrote: > From: Kent Overstreet > > Sent: 11 November 2023 23:39 > > > > On Sat, Nov 11, 2023 at 09:19:40PM +0000, David Laight wrote: > > > From: Kent Overstreet <kent.overstreet@linux.dev> > > > > Sent: 11 November 2023 21:02 > > > > > Variable level is being initialized a value that is never read, the > > > > > variable is being re-assigned another value several statements later > > > > > on. The initialization is redundant and can be removed. Cleans up > > > > > clang scan build warning: > > > > > > > > > > fs/bcachefs/btree_iter.c:1217:11: warning: Value stored to 'level' > > > > > during its initialization is never read [deadcode.DeadStores] > > > > > > > > > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > > > > > > > > since we're no longer gnu89, we can simply declare the variable when > > > > it's first used, like so: > > > > > > ugg... I think that is still frowned upon. > > > It makes it very difficult for the average human to find > > > the variable declaration. > > > > No, it's 2023, there's no good reason to be declaring variables before > > giving them values. > > The year has nothing to do with whether it is a good idea. > It is epically bad without -Wshadow. > (Have you ever played 'stop the declaration' in C++, it isn't fun.) > > Finding declarations is bad enough when they are at the top > of a big block, never mind in the middle of a load of assignments. David, I don't want you giving this kind of advice here, and if finding declarations is something you have trouble with - perhaps find something easier to do.
On Sun, Nov 12, 2023 at 02:12:49PM -0500, Kent Overstreet wrote: > David, I don't want you giving this kind of advice here, and if finding > declarations is something you have trouble with - perhaps find something > easier to do. David is correct. Putting declarations in the middle of code is still frowned on. It's necessary for the __cleanup work and it's okay in for loop iterators but it's generally frowned on. Please don't force people to redo patches in non-standard style. regards, dan carpenter
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c2adf3fbb0b3..bd04aeda37bb 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1214,7 +1214,7 @@ __bch2_btree_path_set_pos(struct btree_trans *trans, struct btree_path *path, struct bpos new_pos, bool intent, unsigned long ip, int cmp) { - unsigned level = path->level; + unsigned level; bch2_trans_verify_not_in_restart(trans); EBUG_ON(!path->ref);