Skip to contentSkip to conversation

mm: shmem: make shmem_init return void

PATCH Applied Miaohe Lin 2 participants 3 messages Mar 28, 2022 – Mar 29, 2022

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 mm: shmem: make shmem_init return void

The return value of shmem_init is never used. So we can make it return void now.

---
 include/linux/shmem_fs.h | 2 +-
 mm/shmem.c               | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
include/linux/shmem_fs.h +1 -1
index ab51d3cd39bd..3e915cc550bc 100644
@@ -56,7 +56,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  * Functions in mm/shmem.c called directly from elsewhere:
  */
 extern const struct fs_parameter_spec shmem_fs_parameters[];
-extern int shmem_init(void);
+extern void shmem_init(void);
 extern int shmem_init_fs_context(struct fs_context *fc);
 extern struct file *shmem_file_setup(const char *name,
 					loff_t size, unsigned long flags);
mm/shmem.c +4 -5
index 529c9ad3e926..26e09a022087 100644
@@ -3879,7 +3879,7 @@ static struct file_system_type shmem_fs_type = {
 	.fs_flags	= FS_USERNS_MOUNT,
 };
 
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
 	int error;
 
@@ -3904,14 +3904,13 @@ int __init shmem_init(void)
 	else
 		shmem_huge = SHMEM_HUGE_NEVER; /* just in case it was patched */
 #endif
-	return 0;
+	return;
 
 out1:
 	unregister_filesystem(&shmem_fs_type);
 out2:
 	shmem_destroy_inodecache();
 	shm_mnt = ERR_PTR(error);
-	return error;
 }
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_SYSFS)
@@ -3989,14 +3988,14 @@ static struct file_system_type shmem_fs_type = {
 	.fs_flags	= FS_USERNS_MOUNT,
 };
 
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
 	BUG_ON(register_filesystem(&shmem_fs_type) != 0);
 
 	shm_mnt = kern_mount(&shmem_fs_type);
 	BUG_ON(IS_ERR(shm_mnt));
 
-	return 0;
+	return;
 }
 
 int shmem_unuse(unsigned int type)
Signature · 1 line
2.23.0
#1 lore raw
Quoted 56 lines · Miaohe Lin

The return value of shmem_init is never used. So we can make it return void now.

---
 include/linux/shmem_fs.h | 2 +-
 mm/shmem.c               | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
include/linux/shmem_fs.h +1 -1
index ab51d3cd39bd..3e915cc550bc 100644
@@ -56,7 +56,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  * Functions in mm/shmem.c called directly from elsewhere:
  */
 extern const struct fs_parameter_spec shmem_fs_parameters[];
-extern int shmem_init(void);
+extern void shmem_init(void);
 extern int shmem_init_fs_context(struct fs_context *fc);
 extern struct file *shmem_file_setup(const char *name,
                                        loff_t size, unsigned long flags);
mm/shmem.c +2 -3
index 529c9ad3e926..26e09a022087 100644
@@ -3879,7 +3879,7 @@ static struct file_system_type shmem_fs_type = {
        .fs_flags       = FS_USERNS_MOUNT,
 };
 
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
        int error;
 
@@ -3904,14 +3904,13 @@ int __init shmem_init(void)
        else
                shmem_huge = SHMEM_HUGE_NEVER; /* just in case it was patched */
 #endif
-       return 0;
+       return;
 
 out1:
        unregister_filesystem(&shmem_fs_type);
 out2:
        shmem_destroy_inodecache();
        shm_mnt = ERR_PTR(error);
-       return error;
 }
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_SYSFS)
@@ -3989,14 +3988,14 @@ static struct file_system_type shmem_fs_type = {
        .fs_flags       = FS_USERNS_MOUNT,
 };
 

mm/shmem.c static struct file_system_type shmem_fs_type = { · line 3998

Quoted 10 lines
mm/shmem.c +2 -2
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
        BUG_ON(register_filesystem(&shmem_fs_type) != 0);
 
        shm_mnt = kern_mount(&shmem_fs_type);
        BUG_ON(IS_ERR(shm_mnt));
 
-       return 0;
+       return;

Weird. Using return at the end of a void function.

author
#2 lore raw
Quoted 62 lines · Muchun Song
Quoted 61 lines · Miaohe Lin

The return value of shmem_init is never used. So we can make it return void now.

---
 include/linux/shmem_fs.h | 2 +-
 mm/shmem.c               | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
include/linux/shmem_fs.h +1 -1
index ab51d3cd39bd..3e915cc550bc 100644
@@ -56,7 +56,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  * Functions in mm/shmem.c called directly from elsewhere:
  */
 extern const struct fs_parameter_spec shmem_fs_parameters[];
-extern int shmem_init(void);
+extern void shmem_init(void);
 extern int shmem_init_fs_context(struct fs_context *fc);
 extern struct file *shmem_file_setup(const char *name,
                                        loff_t size, unsigned long flags);
mm/shmem.c +3 -4
index 529c9ad3e926..26e09a022087 100644
@@ -3879,7 +3879,7 @@ static struct file_system_type shmem_fs_type = {
        .fs_flags       = FS_USERNS_MOUNT,
 };
 
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
        int error;
 
@@ -3904,14 +3904,13 @@ int __init shmem_init(void)
        else
                shmem_huge = SHMEM_HUGE_NEVER; /* just in case it was patched */
 #endif
-       return 0;
+       return;
 
 out1:
        unregister_filesystem(&shmem_fs_type);
 out2:
        shmem_destroy_inodecache();
        shm_mnt = ERR_PTR(error);
-       return error;
 }
 
 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_SYSFS)
@@ -3989,14 +3988,14 @@ static struct file_system_type shmem_fs_type = {
        .fs_flags       = FS_USERNS_MOUNT,
 };
 
-int __init shmem_init(void)
+void __init shmem_init(void)
 {
        BUG_ON(register_filesystem(&shmem_fs_type) != 0);
 
Quoted 7 lines

mm/shmem.c static struct file_system_type shmem_fs_type = { · line 3998

Quoted 5 lines
mm/shmem.c +1 -1
        shm_mnt = kern_mount(&shmem_fs_type);
        BUG_ON(IS_ERR(shm_mnt));
 
-       return 0;
+       return;

Weird. Using return at the end of a void function.

Thanks for review. And thanks Andrew for kindly fixing this. :)

Quoted 2 lines

.