From patchwork Fri Nov 10 19:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 163970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp1350556vqs; Fri, 10 Nov 2023 11:59:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWlJ201dyHrp0MIWV3zIOW8aMCc8PEq1TEENGCzrDfKDw1lWvG3jaYPpiB4rsy/utAV5BF X-Received: by 2002:a17:90b:4ad1:b0:281:3f1e:c26d with SMTP id mh17-20020a17090b4ad100b002813f1ec26dmr10698pjb.45.1699646382725; Fri, 10 Nov 2023 11:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699646382; cv=none; d=google.com; s=arc-20160816; b=C908vfiVisapf2u9xvQXBZCvocy6ejWj2A7c0YHSl1YDR/FyNnpePHy6eosLRtW00l /FqPfaOklRWRtkIT958ZJVpFyYpcWzM4kDpbXSNSHToznD/tQoOzpWp4hCLZdH8ZhEux 1mTdD4A2F8/U4to5azibacvs2wQVtqQAm/fvPL8CwTtrLFrMdIip3X4Nn/tFiFQYlFlx Wkj1hX1fLvy1w2txDG3QOcGZBniwh1jX4OrntYMqSCMjsDk7Dkx7Lh6ILxC9v8AFThwj w+3IPlG3cDJX8vtx3AkQo5gscN3tmrCaKg++6fM4jAAJpIVq1jGMFA55eyXBmkXNkK+a 1V1g== 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=JGFpthYiqaRPY244yP6qRl5S2GlMr+W8XYeFguG1JEM=; fh=62OJw6E3qiSGyMStpfrfFWFPCyAlpTHxOya0Yelu/3M=; b=Yg9HS+w7W3wq0qpkiKP1k7ta2byCje5CGk9HufkD6624glWyOhmdgL4GJPab9D6oHz Nqmd/Fmxft541wPHgt0EZ5Dt8+dNScNATA01aOlrcBYV1vymWPviMBtpjuko0mmlo1nC k9/SgnDxjGB4te/IJGvPzk2dnaNM2wpJ/D5o5oc/tmQ2YZPnoPI7biXvG0iLyrHsBeGP u1FrJ7t+pjYJGLRqo91LQ7R0oEFYMLi84cRgDkkcS7XoIZ83xu/fNUyowFtBIb5DefVV nivpVf53Lp2tRhlaHJJt2w73f6yy2/wPnoiRLBpm73ohPXBnNXeqic0ZIGKZLwVe5Wez ZHng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=sBF5L2r2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id na2-20020a17090b4c0200b0028307e08316si255004pjb.156.2023.11.10.11.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Nov 2023 11:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=sBF5L2r2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 51A2A83058C3; Fri, 10 Nov 2023 11:59:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345454AbjKJT7c (ORCPT + 29 others); Fri, 10 Nov 2023 14:59:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjKJT7b (ORCPT ); Fri, 10 Nov 2023 14:59:31 -0500 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80A9EA9 for ; Fri, 10 Nov 2023 11:59:27 -0800 (PST) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 1Xf2r9Jy2UC9i1Xf2rWXK2; Fri, 10 Nov 2023 20:59:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1699646365; bh=JGFpthYiqaRPY244yP6qRl5S2GlMr+W8XYeFguG1JEM=; h=From:To:Cc:Subject:Date; b=sBF5L2r2secVj5RLVeh89KKXdDCnhOApxbEbYwQRDf1TWzlHI5fsZX1tRpwS+a6kp 5xMS5UHKIUUFVCAaOrMXVP0WhcOjgw3Cg5GN/aw6TAp3he1AFKRmtTx9+PaqL88KS2 AtSdDLpy/oNvAanGcvAsUDhwtbO2xHBd2+TUvVgan2wvtql3yedRnmJOecSTe5E5CD mNFlN7ZtEZwIAF0Y4u41JNYiG2FYkgUhwbShqWsxKgt2sK1wB4yaPbwPB+sT+K1xwS McmyOJEWVkT90BY25TYuubZpD4CeR2tn70bf4mVftWPCA7nnH5fgMZSbwjubRitrHI bYXOVBY9pzKZQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 10 Nov 2023 20:59:25 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Konstantin Komarov Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , ntfs3@lists.linux.dev Subject: [PATCH] fs/ntfs3: Slightly simplify ntfs_inode_printk() Date: Fri, 10 Nov 2023 20:59:22 +0100 Message-Id: <8c9196e6d3b4f5416183a498d3c9ebcf84f22ced.1699646339.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 10 Nov 2023 11:59:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782208405768270121 X-GMAIL-MSGID: 1782208405768270121 The size passed to snprintf() includes the space for the trailing space. So there is no reason here not to use all the available space. So remove the -1 when computing 'name_len'. While at it, use the size of the array directly instead of the intermediate 'name_len' variable. snprintf() also guaranties that the buffer if NULL terminated, so there is no need to write an additional trailing NULL "To be sure". Signed-off-by: Christophe JAILLET --- fs/ntfs3/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 9153dffde950..dcc8984a10a4 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -122,13 +122,12 @@ void ntfs_inode_printk(struct inode *inode, const char *fmt, ...) if (name) { struct dentry *de = d_find_alias(inode); - const u32 name_len = ARRAY_SIZE(s_name_buf) - 1; if (de) { spin_lock(&de->d_lock); - snprintf(name, name_len, " \"%s\"", de->d_name.name); + snprintf(name, sizeof(s_name_buf), " \"%s\"", + de->d_name.name); spin_unlock(&de->d_lock); - name[name_len] = 0; /* To be sure. */ } else { name[0] = 0; }