mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Xichao Zhao <zhao.xichao@vivo.com>, <richard@nod.at>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ubifs: Simplify the code and remove unnecessary parameters.
Date: Mon, 11 Aug 2025 19:27:02 +0800	[thread overview]
Message-ID: <36b86ba2-504a-11b0-ec1b-3b39bd978251@huawei.com> (raw)
In-Reply-To: <20250811101529.436635-1-zhao.xichao@vivo.com>

在 2025/8/11 18:15, Xichao Zhao 写道:
> Remove the parameter '*c' from the ubifs_crc_node function,
> and replace part of the code using ubifs_crc_node.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>   fs/ubifs/io.c    | 13 ++++---------
>   fs/ubifs/ubifs.h |  2 +-
>   2 files changed, 5 insertions(+), 10 deletions(-)
> 

Hi, I think the code of crc calculation in fix_size_in_place() can be 
replaced too. If not, we could make ubifs_crc_node() be static.

> diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
> index a79f229df475..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 */
> @@ -395,7 +392,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 +429,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;
>   }
> @@ -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/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);
> 


      parent reply	other threads:[~2025-08-11 11:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-11 10:15 Xichao Zhao
2025-08-11 10:30 ` Richard Weinberger
2025-08-11 11:27 ` Zhihao Cheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36b86ba2-504a-11b0-ec1b-3b39bd978251@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=zhao.xichao@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®