Skip to content

Commit 3437819

Browse files
dmantipovakpm00
authored andcommitted
ocfs2: avoid extra calls to strlen() after ocfs2_sprintf_system_inode_name()
Since 'ocfs2_sprintf_system_inode_name()' uses 'snprintf()' and returns the number of characters emitted, callers of the former are better to use that return value instead of an explicit calls to 'strlen()'. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Dmitry Antipov <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Reviewed-by: Joel Becker <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a15f37a commit 3437819

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

fs/ocfs2/ioctl.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,11 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
358358
goto bail;
359359
}
360360
} else {
361-
ocfs2_sprintf_system_inode_name(namebuf,
362-
sizeof(namebuf),
363-
type, i);
361+
int len = ocfs2_sprintf_system_inode_name(namebuf,
362+
sizeof(namebuf),
363+
type, i);
364364
status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
365-
namebuf,
366-
strlen(namebuf),
367-
&blkno);
365+
namebuf, len, &blkno);
368366
if (status < 0) {
369367
status = -ENOENT;
370368
goto bail;
@@ -651,12 +649,10 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
651649
goto bail;
652650
}
653651
} else {
654-
ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type,
655-
OCFS2_INVALID_SLOT);
652+
int len = ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf),
653+
type, OCFS2_INVALID_SLOT);
656654
status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
657-
namebuf,
658-
strlen(namebuf),
659-
&blkno);
655+
namebuf, len, &blkno);
660656
if (status < 0) {
661657
status = -ENOENT;
662658
goto bail;

fs/ocfs2/move_extents.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
364364
int *vict_bit,
365365
struct buffer_head **ret_bh)
366366
{
367-
int ret, i, bits_per_unit = 0;
367+
int ret, i, len, bits_per_unit = 0;
368368
u64 blkno;
369369
char namebuf[40];
370370

@@ -375,9 +375,9 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
375375
struct ocfs2_dinode *ac_dinode;
376376
struct ocfs2_group_desc *bg;
377377

378-
ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type, slot);
379-
ret = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf,
380-
strlen(namebuf), &blkno);
378+
len = ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type, slot);
379+
ret = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf, len, &blkno);
380+
381381
if (ret) {
382382
ret = -ENOENT;
383383
goto out;

fs/ocfs2/sysfile.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb,
127127
char namebuf[40];
128128
struct inode *inode = NULL;
129129
u64 blkno;
130-
int status = 0;
130+
int len, status = 0;
131131

132-
ocfs2_sprintf_system_inode_name(namebuf,
133-
sizeof(namebuf),
134-
type, slot);
132+
len = ocfs2_sprintf_system_inode_name(namebuf,
133+
sizeof(namebuf),
134+
type, slot);
135135

136-
status = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf,
137-
strlen(namebuf), &blkno);
136+
status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
137+
namebuf, len, &blkno);
138138
if (status < 0) {
139139
goto bail;
140140
}

0 commit comments

Comments
 (0)