]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hypfs: switch hypfs_create_str() to returning int
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 18 Sep 2025 03:10:49 +0000 (23:10 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 18 Nov 2025 04:59:27 +0000 (23:59 -0500)
Every single caller only cares about PTR_ERR_OR_ZERO() of return value...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/s390/hypfs/hypfs.h
arch/s390/hypfs/hypfs_diag_fs.c
arch/s390/hypfs/hypfs_vm_fs.c
arch/s390/hypfs/inode.c

index 4dc2e068e0ff56b05cc8f19054ee09f99af5d4e7..0d109d956015ff831a3ee1dc722ad8f6576ade29 100644 (file)
@@ -25,8 +25,7 @@ extern struct dentry *hypfs_mkdir(struct dentry *parent, const char *name);
 extern struct dentry *hypfs_create_u64(struct dentry *dir, const char *name,
                                       __u64 value);
 
-extern struct dentry *hypfs_create_str(struct dentry *dir, const char *name,
-                                      char *string);
+extern int hypfs_create_str(struct dentry *dir, const char *name, char *string);
 
 /* LPAR Hypervisor */
 extern int hypfs_diag_init(void);
index ede951dc008587ffb87eecd63654685722a6522a..2178e6060a5da0c1908b52065aa9e8f33c1aefe7 100644 (file)
@@ -228,8 +228,7 @@ static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
                        return PTR_ERR(rc);
        }
        diag224_idx2name(cpu_info__ctidx(diag204_get_info_type(), cpu_info), buffer);
-       rc = hypfs_create_str(cpu_dir, "type", buffer);
-       return PTR_ERR_OR_ZERO(rc);
+       return hypfs_create_str(cpu_dir, "type", buffer);
 }
 
 static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr)
@@ -276,8 +275,7 @@ static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info)
        if (IS_ERR(rc))
                return PTR_ERR(rc);
        diag224_idx2name(phys_cpu__ctidx(diag204_get_info_type(), cpu_info), buffer);
-       rc = hypfs_create_str(cpu_dir, "type", buffer);
-       return PTR_ERR_OR_ZERO(rc);
+       return hypfs_create_str(cpu_dir, "type", buffer);
 }
 
 static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr)
@@ -316,41 +314,25 @@ int hypfs_diag_create_files(struct dentry *root)
                return rc;
 
        systems_dir = hypfs_mkdir(root, "systems");
-       if (IS_ERR(systems_dir)) {
-               rc = PTR_ERR(systems_dir);
-               goto err_out;
-       }
+       if (IS_ERR(systems_dir))
+               return PTR_ERR(systems_dir);
        time_hdr = (struct x_info_blk_hdr *)buffer;
        part_hdr = time_hdr + info_blk_hdr__size(diag204_get_info_type());
        for (i = 0; i < info_blk_hdr__npar(diag204_get_info_type(), time_hdr); i++) {
                part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
-               if (IS_ERR(part_hdr)) {
-                       rc = PTR_ERR(part_hdr);
-                       goto err_out;
-               }
+               if (IS_ERR(part_hdr))
+                       return PTR_ERR(part_hdr);
        }
        if (info_blk_hdr__flags(diag204_get_info_type(), time_hdr) &
            DIAG204_LPAR_PHYS_FLG) {
                ptr = hypfs_create_phys_files(root, part_hdr);
-               if (IS_ERR(ptr)) {
-                       rc = PTR_ERR(ptr);
-                       goto err_out;
-               }
+               if (IS_ERR(ptr))
+                       return PTR_ERR(ptr);
        }
        hyp_dir = hypfs_mkdir(root, "hyp");
-       if (IS_ERR(hyp_dir)) {
-               rc = PTR_ERR(hyp_dir);
-               goto err_out;
-       }
-       ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
-       if (IS_ERR(ptr)) {
-               rc = PTR_ERR(ptr);
-               goto err_out;
-       }
-       rc = 0;
-
-err_out:
-       return rc;
+       if (IS_ERR(hyp_dir))
+               return PTR_ERR(hyp_dir);
+       return hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
 }
 
 /* Diagnose 224 functions */
index 6011289afa8c8ffee7d66be9c0205f9827e417d4..e8a32d66062bf97099e7efe80e6f3aab1fff9725 100644 (file)
@@ -100,11 +100,9 @@ int hypfs_vm_create_files(struct dentry *root)
                rc = PTR_ERR(dir);
                goto failed;
        }
-       file = hypfs_create_str(dir, "type", "z/VM Hypervisor");
-       if (IS_ERR(file)) {
-               rc = PTR_ERR(file);
+       rc = hypfs_create_str(dir, "type", "z/VM Hypervisor");
+       if (rc)
                goto failed;
-       }
 
        /* physical cpus */
        dir = hypfs_mkdir(root, "cpus");
index a4dc8e13d9997025fc8b4a2dc7035f40855de453..c5e2d8932b882fa55caeb6a1b8a6197e61de4701 100644 (file)
@@ -398,24 +398,23 @@ struct dentry *hypfs_create_u64(struct dentry *dir,
        return dentry;
 }
 
-struct dentry *hypfs_create_str(struct dentry *dir,
-                               const char *name, char *string)
+int hypfs_create_str(struct dentry *dir, const char *name, char *string)
 {
        char *buffer;
        struct dentry *dentry;
 
        buffer = kmalloc(strlen(string) + 2, GFP_KERNEL);
        if (!buffer)
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;
        sprintf(buffer, "%s\n", string);
        dentry =
            hypfs_create_file(dir, name, buffer, S_IFREG | REG_FILE_MODE);
        if (IS_ERR(dentry)) {
                kfree(buffer);
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;
        }
        hypfs_add_dentry(dentry);
-       return dentry;
+       return 0;
 }
 
 static const struct file_operations hypfs_file_ops = {