Skip to content

Commit 622cd3d

Browse files
tititiou36aalexandrovich
authored andcommitted
fs/ntfs3: Slightly simplify ntfs_inode_printk()
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>
1 parent 1f5fa4b commit 622cd3d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/ntfs3/super.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ void ntfs_inode_printk(struct inode *inode, const char *fmt, ...)
122122

123123
if (name) {
124124
struct dentry *de = d_find_alias(inode);
125-
const u32 name_len = ARRAY_SIZE(s_name_buf) - 1;
126125

127126
if (de) {
128127
spin_lock(&de->d_lock);
129-
snprintf(name, name_len, " \"%s\"", de->d_name.name);
128+
snprintf(name, sizeof(s_name_buf), " \"%s\"",
129+
de->d_name.name);
130130
spin_unlock(&de->d_lock);
131-
name[name_len] = 0; /* To be sure. */
132131
} else {
133132
name[0] = 0;
134133
}

0 commit comments

Comments
 (0)