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@xxxxxxxxxx> --- 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@xxxxxxxxxx/ 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