Message ID | 4c299692e35a0a14add58a5dd399d07843a4d350.1694934182.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2004462vqi; Sun, 17 Sep 2023 00:06:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfGpleHz+9uDoNR8nKRMTY20xHF8N8EqPrlq6yNgynr7iB3hit3DNGehyknJJgumpmwK4E X-Received: by 2002:a05:6a21:18b:b0:153:616c:7ca4 with SMTP id le11-20020a056a21018b00b00153616c7ca4mr6658381pzb.61.1694934363104; Sun, 17 Sep 2023 00:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694934363; cv=none; d=google.com; s=arc-20160816; b=sIxgpKLNSyt8J6k7om0LDpqe6sW5019tce1Fkng6hwcATEbnMHWnoFN72k2RmGts6b TOtSRO0Hz71UykGW0Dt+vw1w27AfjXaCYJk7fiQHPUubnGJMgvXGAeDLl6fFe8gkH3hK ndRNLbGDggrK4YOefLVbOCrlq6vPgraGyspOnLDRlSFSagPmuYHGc9sDtYRBCuQY1ODc Mb0MO0L7gT/50acmJ6cbJMnwIPyM8gnnuFwYZ/4fFuBAwVh4Td+Pa9itDRGaXi5Ka2h2 N53bG3LQQBL3ljuPw16SwFF+dihqXJeexFlN7UTXB9rJXlHkcKz/f31Hfrij233GfNJQ BX4w== 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=2fqQXXMdIZvdAOxGhxK9XXxf9aMwLimzUQK9Weept9E=; fh=Alfgh8zyUZ02dyiV79lbSPPQIUn93U8MoDCV3a0t/sc=; b=QhmuO2KczAelKRV2w3fZBoLqQb7MdPfSuoNxqE8XH+40l4FI1ScowvHAX06uVXY7DZ fa3su0b8U+yT8IVCa09zFhGZ/w1q7DdrRbN6Ujv/p9j7MKsvLvngDhMq9H/64rPVDqv/ /KYgHnMCRmPKTEuMPdzWZcDuy7JtY+PcpzNazGaI3SkSYBVfslwPeEdVPId67MzF17Ar RiVAyt4yGLXcM0qX38UOC9TOlWLKkV4Jf/gHYufRREkG+38ZPs5fp1+AEvcN7/E4uBPb JvNbVT6QWPw/X7tPKLVFpcyfeliQxvdSO6Qo6pEu5SBIcI3tK8D3Y3rmCkrc/Tq8N2Jv APzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bx88y+Xv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id fa11-20020a056a002d0b00b0068a2e4ba048si6385700pfb.347.2023.09.17.00.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 00:06:03 -0700 (PDT) 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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bx88y+Xv; 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; 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 agentk.vger.email (Postfix) with ESMTP id D058D82BBB4F; Sun, 17 Sep 2023 00:05:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjIQHD4 (ORCPT <rfc822;toshivichauhan@gmail.com> + 29 others); Sun, 17 Sep 2023 03:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbjIQHDm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 17 Sep 2023 03:03:42 -0400 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFC2712D for <linux-kernel@vger.kernel.org>; Sun, 17 Sep 2023 00:03:35 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id hloaqFL4Xr3Xehlobq2VOd; Sun, 17 Sep 2023 09:03:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1694934213; bh=2fqQXXMdIZvdAOxGhxK9XXxf9aMwLimzUQK9Weept9E=; h=From:To:Cc:Subject:Date; b=bx88y+Xvyg2H9W+pXyxhRjj4NoS/c5bSDvXGmSc5u2cwRU11/YekmvOSmlhAW5tdS 2W/xOYiyZLjPOY+PRtnbyiPFmp/RbtP+LX/FFLS9QsHCykOdbkuGKpc5zgu1p7gqzQ kMJYktJKrEwxwPgx7XRJUzcIlkU3QH38pSWcuv223YJM3rW0Xxl26NAncKThJ4OaTG HAevUPMqR+DXtf4tnEmhvlCA1UO6oGgUph9xKDrAhNRWt2F6TQjRTZKNC3CKuJBJEu +U1nhvUrnh099UipBYu9X6s9PN6rctGAPcXCAw4dIC4UnPTFgddefLIGxLe3WEVtGE jDDRzev93RBkA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 17 Sep 2023 09:03:33 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: "Theodore Ts'o" <tytso@mit.edu>, Andreas Dilger <adilger.kernel@dilger.ca> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-ext4@vger.kernel.org Subject: [PATCH v2] ext4: Simplify code in ext4_decode_error() Date: Sun, 17 Sep 2023 09:03:28 +0200 Message-Id: <4c299692e35a0a14add58a5dd399d07843a4d350.1694934182.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 autolearn=unavailable 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: <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 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 00:05:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777267494406412608 X-GMAIL-MSGID: 1777267494406412608 |
Series |
[v2] ext4: Simplify code in ext4_decode_error()
|
|
Commit Message
Christophe JAILLET
Sept. 17, 2023, 7:03 a.m. UTC
snprintf() returns the number of characters which would be generated,
excluding the trailing NULL. Here the value is always >= 7, so the test
is always true.
Instead of fixing the test, just remove it. What matters is that the
string is NULL terminated.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2:
- remove the bogus check, instead of fixing it
- Remove the Fixes tag (was: ac27a0ec112a ("[PATCH] ext4: initial copy of files from ext3"))
v1:
https://lore.kernel.org/all/2c0edffd8557807c6cd6d55111482c5cad7c8f2f.1694275603.git.christophe.jaillet@wanadoo.fr/
The comment about nbuf being NULL or not, and the related test could be
removed, but keeping it is harmless and more future proof.
---
fs/ext4/super.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2684ed69403e..86ed931f402a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -947,9 +947,8 @@ const char *ext4_decode_error(struct super_block *sb, int errno, * errors, textualise them now. Else we just return * NULL. */ if (nbuf) { - /* Check for truncated error codes... */ - if (snprintf(nbuf, 16, "error %d", -errno) >= 0) - errstr = nbuf; + snprintf(nbuf, 16, "error %d", -errno); + errstr = nbuf; } break; }