Re: [PATCH] ubifs: Remove unreachable code

From: Kunwu Chan
Date: Wed Jan 10 2024 - 22:22:07 EST




On 2024/1/5 23:55, Richard Weinberger wrote:
On Sat, Nov 11, 2023 at 3:33 PM Kunwu Chan <chentao@xxxxxxxxxx> wrote:

Because there is no break statement in the dead loop above,it is
impossible to execute the 'err=0' statement.Delete the code that
will never execute and initialize 'err' at the start of the function.

Fixes: 6fb324a4b0c3 ("UBIFS: allocate ltab checking buffer on demand")
Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
---
fs/ubifs/lpt_commit.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c
index c4d079328b92..d4751628fe70 100644
--- a/fs/ubifs/lpt_commit.c
+++ b/fs/ubifs/lpt_commit.c
@@ -1589,8 +1589,8 @@ static int dbg_is_node_dirty(struct ubifs_info *c, int node_type, int lnum,
*/
static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum)
{
- int err, len = c->leb_size, dirty = 0, node_type, node_num, node_len;
- int ret;
+ int len = c->leb_size, dirty = 0, node_type, node_num, node_len;
+ int ret, err = 0;
void *buf, *p;

Now it is still dead code.
A few lines later err will be used for the result of ubifs_leb_read().
So you can remove the initialization of err completely.

Thanks, I will modify in v2 patch.


if (!dbg_is_chk_lprops(c))
@@ -1646,7 +1646,6 @@ static int dbg_check_ltab_lnum(struct ubifs_info *c, int lnum)
len -= node_len;
}

- err = 0;
out:
vfree(buf);
return err;
--
2.34.1