[<prev] [next>] [day] [month] [year] [list]
Message-Id: <4c299692e35a0a14add58a5dd399d07843a4d350.1694934182.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 17 Sep 2023 09:03:28 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: "Theodore Ts'o" <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
linux-ext4@...r.kernel.org
Subject: [PATCH v2] ext4: Simplify code in ext4_decode_error()
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@...adoo.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;
}
--
2.34.1
Powered by blists - more mailing lists