kernfs: Drop unnecessary "mutex" local variable initialization
authorTejun Heo <tj@kernel.org>
Sun, 28 Aug 2022 05:04:33 +0000 (19:04 -1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Sep 2022 16:08:44 +0000 (18:08 +0200)
These are unnecessary and unconventional. Remove them. Also move variable
declaration into the block that it's used. No functional changes.

Cc: Imran Khan <imran.f.khan@oracle.com>
Tested-by: Chengming Zhou <zhouchengming@bytedance.com>
Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20220828050440.734579-3-tj@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/kernfs/file.c

index 32b16fe00a9e015467e6eed02c117467a1d22707..6437f7c7162dff5a1866c316dd399fc43ef54cb9 100644 (file)
@@ -555,7 +555,7 @@ static int kernfs_get_open_node(struct kernfs_node *kn,
                                struct kernfs_open_file *of)
 {
        struct kernfs_open_node *on, *new_on = NULL;
-       struct mutex *mutex = NULL;
+       struct mutex *mutex;
 
        mutex = kernfs_open_file_mutex_lock(kn);
        on = kernfs_deref_open_node_locked(kn);
@@ -599,7 +599,7 @@ static void kernfs_unlink_open_file(struct kernfs_node *kn,
                                 struct kernfs_open_file *of)
 {
        struct kernfs_open_node *on;
-       struct mutex *mutex = NULL;
+       struct mutex *mutex;
 
        mutex = kernfs_open_file_mutex_lock(kn);
 
@@ -776,9 +776,10 @@ static int kernfs_fop_release(struct inode *inode, struct file *filp)
 {
        struct kernfs_node *kn = inode->i_private;
        struct kernfs_open_file *of = kernfs_of(filp);
-       struct mutex *mutex = NULL;
 
        if (kn->flags & KERNFS_HAS_RELEASE) {
+               struct mutex *mutex;
+
                mutex = kernfs_open_file_mutex_lock(kn);
                kernfs_release_file(kn, of);
                mutex_unlock(mutex);
@@ -796,7 +797,7 @@ void kernfs_drain_open_files(struct kernfs_node *kn)
 {
        struct kernfs_open_node *on;
        struct kernfs_open_file *of;
-       struct mutex *mutex = NULL;
+       struct mutex *mutex;
 
        if (!(kn->flags & (KERNFS_HAS_MMAP | KERNFS_HAS_RELEASE)))
                return;