[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250609065615.108240-1-husong@kylinos.cn>
Date: Mon, 9 Jun 2025 14:56:15 +0800
From: Hu Song <husong@...inos.cn>
To: muchun.song@...ux.dev
Cc: osalvador@...e.de,
linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
Hu Song <husong@...inos.cn>
Subject: [PATCH] hugetlbfs:inode: initialize 'error' variable at definition to reduce code redundancy
Initialize the error variable to -ENOMEM at definition in
init_hugetlbfs_fs().This removes the need for a separate
initialization later and makes the code slightly more concise,
while still preserving the original logic.
No functional change intended.
Signed-off-by: Hu Song <husong@...inos.cn>
---
fs/hugetlbfs/inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e4de5425838d..390cddd5872c 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1600,7 +1600,7 @@ static int __init init_hugetlbfs_fs(void)
{
struct vfsmount *mnt;
struct hstate *h;
- int error;
+ int error = -ENOMEM;
int i;
if (!hugepages_supported()) {
@@ -1608,7 +1608,6 @@ static int __init init_hugetlbfs_fs(void)
return -ENOTSUPP;
}
- error = -ENOMEM;
hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
sizeof(struct hugetlbfs_inode_info),
0, SLAB_ACCOUNT, init_once);
--
2.25.1
Powered by blists - more mailing lists