From patchwork Sat Sep 16 07:30:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 141029 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1593085vqi; Sat, 16 Sep 2023 03:55:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3XTAovk96i7R7ws2yELZ9yX5/jnCHlZgFpIb6lsVxqXdaAf2gPH+/pj7JvakMGvkZQH1L X-Received: by 2002:a17:903:41c3:b0:1c4:4a58:ff65 with SMTP id u3-20020a17090341c300b001c44a58ff65mr2841823ple.64.1694861757381; Sat, 16 Sep 2023 03:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694861757; cv=none; d=google.com; s=arc-20160816; b=KF8nZWAjcTB6bPmS+2STgnrT5zpcgmDabwlz39wMublxnsAbj4xo6Pq/je4iupYGpc FcU92XPmxB8kx+KDiK3+tumK7hbOEbMskve0sXaKsv+Nzu4I+oDec29dw9YrOGC1G2Z8 SYUdsyj1YIBkYi4rBr+VXYDLR2fnbdVBsoHhOmJZ0msHIXcrGg6cTrP0FnqMWZSzPSmC Rrcbh46kl4Nspw0M45fYsRqNndOC1Z13/1FfuOORcFPaNEDGC6wMHs1sKk9Vrs8uwSXU ePNtVh4UQuDhr8grUfsBcBi2RkTaC7n9mCsS5ju80PfsYL8vUJcvqI0gEVfXZJGUxZLQ OqdQ== 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=FCzGUfVfl3gyXvyMuMWEuajChRiIpmEDWmkcE4/V2oA=; fh=m3UyueLH4KDy0H9ZPaSnoQRYWYiD76Xl1Jq/Gorb8Ss=; b=r1MTtdAFAEcpur3+ABNrHVyL1wJ+K7Gwy8mbNM3D1hGGLawxxbFMlJiuraW3iSjJpQ oM9kAjeILj19QcqT6KXB+TEonkBLRre4vTn5W1uuS4Oljgl/DXPq8/d5Z3uXv6QUc6g9 Mo9BzDDwnItGGjJExGFEOwB/Y/BA2DTXApKXV20PQWUV+fy8doK/Hj3+ra20FKQlEJZX BmhCM4OspBq+AASdOAQ2lyYiuPfkoJEcUVAgJRxFRC5NEUHucr/dr7if7SIE9BJnwqLb eSZig9mTZ4hGFdENyFH5yhV15N0zXkQ+CVz3WP9N7XCc6MXFGLZcmnQMzKgmEH44pRzv 9d4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bj5eJ+Ep; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r18-20020a170902be1200b001b5589848absi4766769pls.234.2023.09.16.03.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 03:55:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bj5eJ+Ep; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3253284D5731; Sat, 16 Sep 2023 00:31:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbjIPHa7 (ORCPT + 27 others); Sat, 16 Sep 2023 03:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbjIPHa3 (ORCPT ); Sat, 16 Sep 2023 03:30:29 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBE710D4 for ; Sat, 16 Sep 2023 00:30:23 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id hPkzqXWcGBLWLhPkzqni2a; Sat, 16 Sep 2023 09:30:22 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1694849422; bh=FCzGUfVfl3gyXvyMuMWEuajChRiIpmEDWmkcE4/V2oA=; h=From:To:Cc:Subject:Date; b=bj5eJ+EpYft4no84HOrXdiDq5nzVL9vVG65EmhQgoM+uUPmKRJwuX5QWFsk0LsTgm pqPKT8vemhX3ZmpzoDYR2+sVOn2MEeAN1cRnp6rRRcFwTyTTVPdrr8xj5oa8WHq9NL Qw9wmVBBCqnwycFUd9TVZzp1UkpYdcNyLV9fFXubg9jZ7Jp1X1WZyBZFdpqMaR3XrB cehOkz8dLPiWpFCfMXc4yDqhAOrWS49eT1eZUEqpM/N0zdhSigyBL2O3LZ8fR16E0a IOyerjRtCULOvgQAIN0/Rs0lLOQ7dKFGQoXKp2oJHpTBU/uAH1bjzOW0To80ZaPSmY W1nIE7qwIxp/w== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 16 Sep 2023 09:30:22 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Kent Overstreet , Brian Foster Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-bcachefs@vger.kernel.org Subject: [PATCH] bcachefs: Use snprintf() instead of scnprintf() when appropriate Date: Sat, 16 Sep 2023 09:30:19 +0200 Message-Id: <9a998be3e2dbedcd3a9eae5f81ae6dcc6c0f98c4.1694849375.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Sat, 16 Sep 2023 00:31:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777191361927854359 X-GMAIL-MSGID: 1777191361927854359 snprintf() and scnprintf() are the same, except for the returned value. When this value is not used, it is more logical to use snprintf() which is slightly simpler. Signed-off-by: Christophe JAILLET Reviewed-by: Brian Foster --- fs/bcachefs/super.c | 2 +- fs/bcachefs/tests.c | 2 +- fs/bcachefs/trace.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 2990eed85adf..773ea93e44c1 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1180,7 +1180,7 @@ static void bch2_dev_attach(struct bch_fs *c, struct bch_dev *ca, { ca->dev_idx = dev_idx; __set_bit(ca->dev_idx, ca->self.d); - scnprintf(ca->name, sizeof(ca->name), "dev-%u", dev_idx); + snprintf(ca->name, sizeof(ca->name), "dev-%u", dev_idx); ca->fs = c; rcu_assign_pointer(c->devs[ca->dev_idx], ca); diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c index c907b3e00176..72f9bf186f9c 100644 --- a/fs/bcachefs/tests.c +++ b/fs/bcachefs/tests.c @@ -926,7 +926,7 @@ int bch2_btree_perf_test(struct bch_fs *c, const char *testname, time = j.finish - j.start; - scnprintf(name_buf, sizeof(name_buf), "%s:", testname); + snprintf(name_buf, sizeof(name_buf), "%s:", testname); prt_human_readable_u64(&nr_buf, nr); prt_human_readable_u64(&per_sec_buf, div64_u64(nr * NSEC_PER_SEC, time)); printk(KERN_INFO "%-12s %s with %u threads in %5llu sec, %5llu nsec per iter, %5s per sec\n", diff --git a/fs/bcachefs/trace.h b/fs/bcachefs/trace.h index 19264492151b..da303dd4b71c 100644 --- a/fs/bcachefs/trace.h +++ b/fs/bcachefs/trace.h @@ -450,7 +450,7 @@ TRACE_EVENT(btree_path_relock_fail, c = six_lock_counts(&path->l[level].b->c.lock); __entry->read_count = c.n[SIX_LOCK_read]; __entry->intent_count = c.n[SIX_LOCK_intent]; - scnprintf(__entry->node, sizeof(__entry->node), "%px", b); + snprintf(__entry->node, sizeof(__entry->node), "%px", b); } __entry->iter_lock_seq = path->l[level].lock_seq; __entry->node_lock_seq = is_btree_node(path, level)