* [PATCH v2 0/2] ubifs: Simplify the code and remove unnecessary parameters
@ 2025-08-12 2:10 Xichao Zhao
2025-08-12 2:10 ` [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c' Xichao Zhao
2025-08-12 2:10 ` [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node Xichao Zhao
0 siblings, 2 replies; 5+ messages in thread
From: Xichao Zhao @ 2025-08-12 2:10 UTC (permalink / raw)
To: Richard Weinberger, Zhihao Cheng,
open list:UBI FILE SYSTEM (UBIFS), open list
Cc: Xichao Zhao
Remove the parameter '*c' from the ubifs_crc_node function,
and replace part of the code using ubifs_crc_node.
Xichao Zhao (2):
ubifs: Remove unnecessary parameters '*c'
ubifs: Simplify the code
fs/ubifs/io.c | 13 ++++---------
fs/ubifs/recovery.c | 4 +---
fs/ubifs/ubifs.h | 2 +-
3 files changed, 6 insertions(+), 13 deletions(-)
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c'
2025-08-12 2:10 [PATCH v2 0/2] ubifs: Simplify the code and remove unnecessary parameters Xichao Zhao
@ 2025-08-12 2:10 ` Xichao Zhao
2025-08-12 3:06 ` Zhihao Cheng
2025-08-12 2:10 ` [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node Xichao Zhao
1 sibling, 1 reply; 5+ messages in thread
From: Xichao Zhao @ 2025-08-12 2:10 UTC (permalink / raw)
To: Richard Weinberger, Zhihao Cheng,
open list:UBI FILE SYSTEM (UBIFS), open list
Cc: Xichao Zhao
Because the variable *c is not used within the function,
remove it from the ubifs_crc_node function.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
fs/ubifs/io.c | 4 ++--
fs/ubifs/ubifs.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index a79f229df475..e0dfe6827d65 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -395,7 +395,7 @@ void ubifs_init_node(struct ubifs_info *c, void *node, int len, int pad)
}
}
-void ubifs_crc_node(struct ubifs_info *c, void *node, int len)
+void ubifs_crc_node(void *node, int len)
{
struct ubifs_ch *ch = node;
uint32_t crc;
@@ -432,7 +432,7 @@ int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
return err;
}
- ubifs_crc_node(c, node, len);
+ ubifs_crc_node(node, len);
return 0;
}
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 5db45c9e26ee..5d172509091a 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1743,7 +1743,7 @@ int ubifs_write_node_hmac(struct ubifs_info *c, void *buf, int len, int lnum,
int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
int lnum, int offs, int quiet, int must_chk_crc);
void ubifs_init_node(struct ubifs_info *c, void *buf, int len, int pad);
-void ubifs_crc_node(struct ubifs_info *c, void *buf, int len);
+void ubifs_crc_node(void *buf, int len);
void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
int hmac_offs, int pad);
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node
2025-08-12 2:10 [PATCH v2 0/2] ubifs: Simplify the code and remove unnecessary parameters Xichao Zhao
2025-08-12 2:10 ` [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c' Xichao Zhao
@ 2025-08-12 2:10 ` Xichao Zhao
2025-08-12 3:06 ` Zhihao Cheng
1 sibling, 1 reply; 5+ messages in thread
From: Xichao Zhao @ 2025-08-12 2:10 UTC (permalink / raw)
To: Richard Weinberger, Zhihao Cheng,
open list:UBI FILE SYSTEM (UBIFS), open list
Cc: Xichao Zhao
Replace part of the code using ubifs_crc_node.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
fs/ubifs/io.c | 9 ++-------
fs/ubifs/recovery.c | 4 +---
2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index e0dfe6827d65..6c6d68242779 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -327,8 +327,6 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
*/
void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
{
- uint32_t crc;
-
ubifs_assert(c, pad >= 0);
if (pad >= UBIFS_PAD_NODE_SZ) {
@@ -343,8 +341,7 @@ void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
ch->len = cpu_to_le32(UBIFS_PAD_NODE_SZ);
pad -= UBIFS_PAD_NODE_SZ;
pad_node->pad_len = cpu_to_le32(pad);
- crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8);
- ch->crc = cpu_to_le32(crc);
+ ubifs_crc_node(buf, UBIFS_PAD_NODE_SZ);
memset(buf + UBIFS_PAD_NODE_SZ, 0, pad);
} else if (pad > 0)
/* Too little space, padding node won't fit */
@@ -469,7 +466,6 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
*/
void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
{
- uint32_t crc;
struct ubifs_ch *ch = node;
unsigned long long sqnum = next_sqnum(c);
@@ -483,8 +479,7 @@ void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
ch->group_type = UBIFS_IN_NODE_GROUP;
ch->sqnum = cpu_to_le64(sqnum);
ch->padding[0] = ch->padding[1] = 0;
- crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
- ch->crc = cpu_to_le32(crc);
+ ubifs_crc_node(node, len);
}
/**
diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
index f0d51dd21c9e..b36dc9b032f4 100644
--- a/fs/ubifs/recovery.c
+++ b/fs/ubifs/recovery.c
@@ -1406,7 +1406,6 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
union ubifs_key key;
int err, lnum, offs, len;
loff_t i_size;
- uint32_t crc;
/* Locate the inode node LEB number and offset */
ino_key_init(c, &key, e->inum);
@@ -1428,8 +1427,7 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
ino = c->sbuf + offs;
ino->size = cpu_to_le64(e->d_size);
len = le32_to_cpu(ino->ch.len);
- crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8);
- ino->ch.crc = cpu_to_le32(crc);
+ ubifs_crc_node((void *)ino, len);
/* Work out where data in the LEB ends and free space begins */
p = c->sbuf;
len = c->leb_size - 1;
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c'
2025-08-12 2:10 ` [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c' Xichao Zhao
@ 2025-08-12 3:06 ` Zhihao Cheng
0 siblings, 0 replies; 5+ messages in thread
From: Zhihao Cheng @ 2025-08-12 3:06 UTC (permalink / raw)
To: Xichao Zhao, Richard Weinberger,
open list:UBI FILE SYSTEM (UBIFS), open list
在 2025/8/12 10:10, Xichao Zhao 写道:
> Because the variable *c is not used within the function,
> remove it from the ubifs_crc_node function.
>
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
> fs/ubifs/io.c | 4 ++--
> fs/ubifs/ubifs.h | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
>
> diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
> index a79f229df475..e0dfe6827d65 100644
> --- a/fs/ubifs/io.c
> +++ b/fs/ubifs/io.c
> @@ -395,7 +395,7 @@ void ubifs_init_node(struct ubifs_info *c, void *node, int len, int pad)
> }
> }
>
> -void ubifs_crc_node(struct ubifs_info *c, void *node, int len)
> +void ubifs_crc_node(void *node, int len)
> {
> struct ubifs_ch *ch = node;
> uint32_t crc;
> @@ -432,7 +432,7 @@ int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
> return err;
> }
>
> - ubifs_crc_node(c, node, len);
> + ubifs_crc_node(node, len);
>
> return 0;
> }
> diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
> index 5db45c9e26ee..5d172509091a 100644
> --- a/fs/ubifs/ubifs.h
> +++ b/fs/ubifs/ubifs.h
> @@ -1743,7 +1743,7 @@ int ubifs_write_node_hmac(struct ubifs_info *c, void *buf, int len, int lnum,
> int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
> int lnum, int offs, int quiet, int must_chk_crc);
> void ubifs_init_node(struct ubifs_info *c, void *buf, int len, int pad);
> -void ubifs_crc_node(struct ubifs_info *c, void *buf, int len);
> +void ubifs_crc_node(void *buf, int len);
> void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
> int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
> int hmac_offs, int pad);
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node
2025-08-12 2:10 ` [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node Xichao Zhao
@ 2025-08-12 3:06 ` Zhihao Cheng
0 siblings, 0 replies; 5+ messages in thread
From: Zhihao Cheng @ 2025-08-12 3:06 UTC (permalink / raw)
To: Xichao Zhao, Richard Weinberger,
open list:UBI FILE SYSTEM (UBIFS), open list
在 2025/8/12 10:10, Xichao Zhao 写道:
> Replace part of the code using ubifs_crc_node.
>
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
> fs/ubifs/io.c | 9 ++-------
> fs/ubifs/recovery.c | 4 +---
> 2 files changed, 3 insertions(+), 10 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
> index e0dfe6827d65..6c6d68242779 100644
> --- a/fs/ubifs/io.c
> +++ b/fs/ubifs/io.c
> @@ -327,8 +327,6 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
> */
> void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
> {
> - uint32_t crc;
> -
> ubifs_assert(c, pad >= 0);
>
> if (pad >= UBIFS_PAD_NODE_SZ) {
> @@ -343,8 +341,7 @@ void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
> ch->len = cpu_to_le32(UBIFS_PAD_NODE_SZ);
> pad -= UBIFS_PAD_NODE_SZ;
> pad_node->pad_len = cpu_to_le32(pad);
> - crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8);
> - ch->crc = cpu_to_le32(crc);
> + ubifs_crc_node(buf, UBIFS_PAD_NODE_SZ);
> memset(buf + UBIFS_PAD_NODE_SZ, 0, pad);
> } else if (pad > 0)
> /* Too little space, padding node won't fit */
> @@ -469,7 +466,6 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
> */
> void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
> {
> - uint32_t crc;
> struct ubifs_ch *ch = node;
> unsigned long long sqnum = next_sqnum(c);
>
> @@ -483,8 +479,7 @@ void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
> ch->group_type = UBIFS_IN_NODE_GROUP;
> ch->sqnum = cpu_to_le64(sqnum);
> ch->padding[0] = ch->padding[1] = 0;
> - crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
> - ch->crc = cpu_to_le32(crc);
> + ubifs_crc_node(node, len);
> }
>
> /**
> diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
> index f0d51dd21c9e..b36dc9b032f4 100644
> --- a/fs/ubifs/recovery.c
> +++ b/fs/ubifs/recovery.c
> @@ -1406,7 +1406,6 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
> union ubifs_key key;
> int err, lnum, offs, len;
> loff_t i_size;
> - uint32_t crc;
>
> /* Locate the inode node LEB number and offset */
> ino_key_init(c, &key, e->inum);
> @@ -1428,8 +1427,7 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
> ino = c->sbuf + offs;
> ino->size = cpu_to_le64(e->d_size);
> len = le32_to_cpu(ino->ch.len);
> - crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8);
> - ino->ch.crc = cpu_to_le32(crc);
> + ubifs_crc_node((void *)ino, len);
> /* Work out where data in the LEB ends and free space begins */
> p = c->sbuf;
> len = c->leb_size - 1;
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-12 3:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-12 2:10 [PATCH v2 0/2] ubifs: Simplify the code and remove unnecessary parameters Xichao Zhao
2025-08-12 2:10 ` [PATCH v2 1/2] ubifs: Remove unnecessary parameters '*c' Xichao Zhao
2025-08-12 3:06 ` Zhihao Cheng
2025-08-12 2:10 ` [PATCH v2 2/2] ubifs: Simplify the code using ubifs_crc_node Xichao Zhao
2025-08-12 3:06 ` Zhihao Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).