mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ubifs: Remove unnecessary variable assignments
@ 2025-08-11 10:09 Xichao Zhao
  2025-08-11 11:15 ` Zhihao Cheng
  0 siblings, 1 reply; 2+ messages in thread
From: Xichao Zhao @ 2025-08-11 10:09 UTC (permalink / raw)
  To: richard; +Cc: chengzhihao1, linux-mtd, linux-kernel, Xichao Zhao

When an error occurs, ubifs_err is used to directly print the error,
and different errors have different formats for printing. Therefore,
it's not necessary to use 'err' to locate the error occurrence.
Thus, remove the relevant assignments to 'err'.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 fs/ubifs/tnc_misc.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
index d3f8a6aa1f49..10b222dc6a53 100644
--- a/fs/ubifs/tnc_misc.c
+++ b/fs/ubifs/tnc_misc.c
@@ -321,7 +321,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 			  c->fanout, znode->child_cnt);
 		ubifs_err(c, "max levels %d, znode level %d",
 			  UBIFS_MAX_LEVELS, znode->level);
-		err = 1;
 		goto out_dump;
 	}
 
@@ -342,7 +341,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 		    zbr->lnum >= c->leb_cnt || zbr->offs < 0 ||
 		    zbr->offs + zbr->len > c->leb_size || zbr->offs & 7) {
 			ubifs_err(c, "bad branch %d", i);
-			err = 2;
 			goto out_dump;
 		}
 
@@ -355,7 +353,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 		default:
 			ubifs_err(c, "bad key type at slot %d: %d",
 				  i, key_type(c, &zbr->key));
-			err = 3;
 			goto out_dump;
 		}
 
@@ -368,7 +365,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 				ubifs_err(c, "bad target node (type %d) length (%d)",
 					  type, zbr->len);
 				ubifs_err(c, "have to be %d", c->ranges[type].len);
-				err = 4;
 				goto out_dump;
 			}
 		} else if (zbr->len < c->ranges[type].min_len ||
@@ -378,7 +374,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 			ubifs_err(c, "have to be in range of %d-%d",
 				  c->ranges[type].min_len,
 				  c->ranges[type].max_len);
-			err = 5;
 			goto out_dump;
 		}
 	}
@@ -396,13 +391,11 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 		cmp = keys_cmp(c, key1, key2);
 		if (cmp > 0) {
 			ubifs_err(c, "bad key order (keys %d and %d)", i, i + 1);
-			err = 6;
 			goto out_dump;
 		} else if (cmp == 0 && !is_hash_key(c, key1)) {
 			/* These can only be keys with colliding hash */
 			ubifs_err(c, "keys %d and %d are not hashed but equivalent",
 				  i, i + 1);
-			err = 7;
 			goto out_dump;
 		}
 	}
@@ -411,7 +404,7 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
 	return 0;
 
 out_dump:
-	ubifs_err(c, "bad indexing node at LEB %d:%d, error %d", lnum, offs, err);
+	ubifs_err(c, "bad indexing node at LEB %d:%d", lnum, offs);
 	ubifs_dump_node(c, idx, c->max_idx_node_sz);
 	kfree(idx);
 	return -EINVAL;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ubifs: Remove unnecessary variable assignments
  2025-08-11 10:09 [PATCH] ubifs: Remove unnecessary variable assignments Xichao Zhao
@ 2025-08-11 11:15 ` Zhihao Cheng
  0 siblings, 0 replies; 2+ messages in thread
From: Zhihao Cheng @ 2025-08-11 11:15 UTC (permalink / raw)
  To: Xichao Zhao, richard; +Cc: linux-mtd, linux-kernel

在 2025/8/11 18:09, Xichao Zhao 写道:
> When an error occurs, ubifs_err is used to directly print the error,
> and different errors have different formats for printing. Therefore,
> it's not necessary to use 'err' to locate the error occurrence.
> Thus, remove the relevant assignments to 'err'.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>   fs/ubifs/tnc_misc.c | 9 +--------
>   1 file changed, 1 insertion(+), 8 deletions(-)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
> index d3f8a6aa1f49..10b222dc6a53 100644
> --- a/fs/ubifs/tnc_misc.c
> +++ b/fs/ubifs/tnc_misc.c
> @@ -321,7 +321,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   			  c->fanout, znode->child_cnt);
>   		ubifs_err(c, "max levels %d, znode level %d",
>   			  UBIFS_MAX_LEVELS, znode->level);
> -		err = 1;
>   		goto out_dump;
>   	}
>   
> @@ -342,7 +341,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   		    zbr->lnum >= c->leb_cnt || zbr->offs < 0 ||
>   		    zbr->offs + zbr->len > c->leb_size || zbr->offs & 7) {
>   			ubifs_err(c, "bad branch %d", i);
> -			err = 2;
>   			goto out_dump;
>   		}
>   
> @@ -355,7 +353,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   		default:
>   			ubifs_err(c, "bad key type at slot %d: %d",
>   				  i, key_type(c, &zbr->key));
> -			err = 3;
>   			goto out_dump;
>   		}
>   
> @@ -368,7 +365,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   				ubifs_err(c, "bad target node (type %d) length (%d)",
>   					  type, zbr->len);
>   				ubifs_err(c, "have to be %d", c->ranges[type].len);
> -				err = 4;
>   				goto out_dump;
>   			}
>   		} else if (zbr->len < c->ranges[type].min_len ||
> @@ -378,7 +374,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   			ubifs_err(c, "have to be in range of %d-%d",
>   				  c->ranges[type].min_len,
>   				  c->ranges[type].max_len);
> -			err = 5;
>   			goto out_dump;
>   		}
>   	}
> @@ -396,13 +391,11 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   		cmp = keys_cmp(c, key1, key2);
>   		if (cmp > 0) {
>   			ubifs_err(c, "bad key order (keys %d and %d)", i, i + 1);
> -			err = 6;
>   			goto out_dump;
>   		} else if (cmp == 0 && !is_hash_key(c, key1)) {
>   			/* These can only be keys with colliding hash */
>   			ubifs_err(c, "keys %d and %d are not hashed but equivalent",
>   				  i, i + 1);
> -			err = 7;
>   			goto out_dump;
>   		}
>   	}
> @@ -411,7 +404,7 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
>   	return 0;
>   
>   out_dump:
> -	ubifs_err(c, "bad indexing node at LEB %d:%d, error %d", lnum, offs, err);
> +	ubifs_err(c, "bad indexing node at LEB %d:%d", lnum, offs);
>   	ubifs_dump_node(c, idx, c->max_idx_node_sz);
>   	kfree(idx);
>   	return -EINVAL;
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-11 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11 10:09 [PATCH] ubifs: Remove unnecessary variable assignments Xichao Zhao
2025-08-11 11:15 ` Zhihao Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®