]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ocfs2: avoid extra calls to strlen() after ocfs2_sprintf_system_inode_name()
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 17 Sep 2025 06:02:29 +0000 (09:02 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 23 Sep 2025 03:11:00 +0000 (20:11 -0700)
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/20250917060229.1854335-1-dmantipov@yandex.ru
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/ioctl.c
fs/ocfs2/move_extents.c
fs/ocfs2/sysfile.c

index db14c92302a14b64d4b9596fd7985f6918bf179a..b6864602814c49edb48007dc852fe7d628be9f20 100644 (file)
@@ -358,13 +358,11 @@ static int ocfs2_info_handle_freeinode(struct inode *inode,
                                goto bail;
                        }
                } else {
-                       ocfs2_sprintf_system_inode_name(namebuf,
-                                                       sizeof(namebuf),
-                                                       type, i);
+                       int len = ocfs2_sprintf_system_inode_name(namebuf,
+                                                                 sizeof(namebuf),
+                                                                 type, i);
                        status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
-                                                           namebuf,
-                                                           strlen(namebuf),
-                                                           &blkno);
+                                                           namebuf, len, &blkno);
                        if (status < 0) {
                                status = -ENOENT;
                                goto bail;
@@ -651,12 +649,10 @@ static int ocfs2_info_handle_freefrag(struct inode *inode,
                        goto bail;
                }
        } else {
-               ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type,
-                                               OCFS2_INVALID_SLOT);
+               int len = ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf),
+                                                         type, OCFS2_INVALID_SLOT);
                status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
-                                                   namebuf,
-                                                   strlen(namebuf),
-                                                   &blkno);
+                                                   namebuf, len, &blkno);
                if (status < 0) {
                        status = -ENOENT;
                        goto bail;
index cbe2f8ed88974f81e97d95dae1e129bb6a89885c..86f2631e63601fa7aca544e196d9ee423d36babb 100644 (file)
@@ -364,7 +364,7 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
                                         int *vict_bit,
                                         struct buffer_head **ret_bh)
 {
-       int ret, i, bits_per_unit = 0;
+       int ret, i, len, bits_per_unit = 0;
        u64 blkno;
        char namebuf[40];
 
@@ -375,9 +375,9 @@ static int ocfs2_find_victim_alloc_group(struct inode *inode,
        struct ocfs2_dinode *ac_dinode;
        struct ocfs2_group_desc *bg;
 
-       ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type, slot);
-       ret = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf,
-                                        strlen(namebuf), &blkno);
+       len = ocfs2_sprintf_system_inode_name(namebuf, sizeof(namebuf), type, slot);
+       ret = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf, len, &blkno);
+
        if (ret) {
                ret = -ENOENT;
                goto out;
index 53a945da873bc06790a89a4efa92fa4fa5835c25..d53a6cc866bef627f4ca5a986eb326ea9a7c7f7c 100644 (file)
@@ -127,14 +127,14 @@ static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb,
        char namebuf[40];
        struct inode *inode = NULL;
        u64 blkno;
-       int status = 0;
+       int len, status = 0;
 
-       ocfs2_sprintf_system_inode_name(namebuf,
-                                       sizeof(namebuf),
-                                       type, slot);
+       len = ocfs2_sprintf_system_inode_name(namebuf,
+                                             sizeof(namebuf),
+                                             type, slot);
 
-       status = ocfs2_lookup_ino_from_name(osb->sys_root_inode, namebuf,
-                                           strlen(namebuf), &blkno);
+       status = ocfs2_lookup_ino_from_name(osb->sys_root_inode,
+                                           namebuf, len, &blkno);
        if (status < 0) {
                goto bail;
        }