]> git.itanic.dy.fi Git - linux-stable/commitdiff
fs/ntfs3: Slightly simplify ntfs_inode_printk()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 10 Nov 2023 19:59:22 +0000 (20:59 +0100)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Mon, 29 Jan 2024 09:05:09 +0000 (12:05 +0300)
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 <christophe.jaillet@wanadoo.fr>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/super.c

index c55a29793a8d87f79fddbce02425dd06520f7fa8..cef5467fd92833aec6fb0bce3879826c2a627a09 100644 (file)
@@ -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;
                }