Re: [PATCH] fs/ocfs2: remove redundant ret variable

From: Joseph Qi
Date: Tue Jan 04 2022 - 21:04:28 EST




On 1/4/22 7:23 PM, cgel.zte@xxxxxxxxx wrote:
> From: Minghao Chi <chi.minghao@xxxxxxxxxx>
>
> Return value from dlm_lock() directly instead
> of taking this in another redundant variable.
>
> Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
> Signed-off-by: Minghao Chi <chi.minghao@xxxxxxxxxx>
> Signed-off-by: CGEL ZTE <cgel.zte@xxxxxxxxx>
> ---
> fs/ocfs2/stack_user.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
> index 85a47621e0c0..3027a6a05668 100644
> --- a/fs/ocfs2/stack_user.c
> +++ b/fs/ocfs2/stack_user.c
> @@ -683,28 +683,23 @@ static int user_dlm_lock(struct ocfs2_cluster_connection *conn,
> void *name,
> unsigned int namelen)
> {
> - int ret;
> -
> if (!lksb->lksb_fsdlm.sb_lvbptr)
> lksb->lksb_fsdlm.sb_lvbptr = (char *)lksb +
> sizeof(struct dlm_lksb);
>
> - ret = dlm_lock(conn->cc_lockspace, mode, &lksb->lksb_fsdlm,
> + return dlm_lock(conn->cc_lockspace, mode, &lksb->lksb_fsdlm,
> flags|DLM_LKF_NODLCKWT, name, namelen, 0,
> fsdlm_lock_ast_wrapper, lksb,
> fsdlm_blocking_ast_wrapper);

Better to align the parameters as well.

Thanks,
Joseph

> - return ret;
> }
>
> static int user_dlm_unlock(struct ocfs2_cluster_connection *conn,
> struct ocfs2_dlm_lksb *lksb,
> u32 flags)
> {
> - int ret;
>
> - ret = dlm_unlock(conn->cc_lockspace, lksb->lksb_fsdlm.sb_lkid,
> + return dlm_unlock(conn->cc_lockspace, lksb->lksb_fsdlm.sb_lkid,
> flags, &lksb->lksb_fsdlm, lksb);
> - return ret;
> }
>
> static int user_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)