2022-08-23 02:21:27

by Zeng Heng

[permalink] [raw]
Subject: [PATCH -next] xfs: remove redundant else for clean code

"else" is not generally useful after a return, so remove it for clean code.

There is no logical changes.

Signed-off-by: Zeng Heng <[email protected]>
---
fs/xfs/xfs_log.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 386b0307aed8..f6e7e4fd72ae 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -226,12 +226,12 @@ xlog_ticket_reservation(
if (head == &log->l_write_head) {
ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV);
return tic->t_unit_res;
- } else {
- if (tic->t_flags & XLOG_TIC_PERM_RESERV)
- return tic->t_unit_res * tic->t_cnt;
- else
- return tic->t_unit_res;
}
+
+ if (tic->t_flags & XLOG_TIC_PERM_RESERV)
+ return tic->t_unit_res * tic->t_cnt;
+
+ return tic->t_unit_res;
}

STATIC bool
--
2.25.1


2022-08-23 17:12:21

by Darrick J. Wong

[permalink] [raw]
Subject: Re: [PATCH -next] xfs: remove redundant else for clean code

On Tue, Aug 23, 2022 at 09:47:45AM +0800, Zeng Heng wrote:
> "else" is not generally useful after a return, so remove it for clean code.
>
> There is no logical changes.
>
> Signed-off-by: Zeng Heng <[email protected]>
> ---
> fs/xfs/xfs_log.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 386b0307aed8..f6e7e4fd72ae 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -226,12 +226,12 @@ xlog_ticket_reservation(
> if (head == &log->l_write_head) {
> ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV);
> return tic->t_unit_res;
> - } else {
> - if (tic->t_flags & XLOG_TIC_PERM_RESERV)
> - return tic->t_unit_res * tic->t_cnt;
> - else
> - return tic->t_unit_res;
> }
> +
> + if (tic->t_flags & XLOG_TIC_PERM_RESERV)
> + return tic->t_unit_res * tic->t_cnt;
> +
> + return tic->t_unit_res;

I think this looks correct
Reviewed-by: Darrick J. Wong <[email protected]>

--D

> }
>
> STATIC bool
> --
> 2.25.1
>