Re: [PATCH] kernfs: Simplify if--else codes

From: Greg KH
Date: Mon Jun 28 2021 - 02:47:53 EST


On Sun, Jun 27, 2021 at 11:01:55PM -0700, 13145886936@xxxxxxx wrote:
> From: gushengxian <gushengxian@xxxxxxxxxx>
>
> Simplify if--else codes.
>
> Signed-off-by: gushengxian <13145886936@xxxxxxx>
> Signed-off-by: gushengxian <gushengxian@xxxxxxxxxx>
> ---
> fs/kernfs/file.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> index c75719312147..6bd531419f30 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -644,10 +644,7 @@ static int kernfs_fop_open(struct inode *inode, struct file *file)
> * Both paths of the branch look the same. They're supposed to
> * look that way and give @of->mutex different static lockdep keys.
> */
> - if (has_mmap)
> - mutex_init(&of->mutex);
> - else
> - mutex_init(&of->mutex);
> + mutex_init(&of->mutex);

Please always read the code, and the comments, you are modifying before
you modify it :(

This is a sign you are doing "blind" code cleanups. Please stick with
drivers/staging/ for now as that part of the kernel accepts them much
easier than the rest of the kernel does.

thanks,

greg k-h