]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ubifs: Simplify the code using ubifs_crc_node
authorXichao Zhao <zhao.xichao@vivo.com>
Tue, 12 Aug 2025 02:10:08 +0000 (10:10 +0800)
committerRichard Weinberger <richard@nod.at>
Fri, 28 Nov 2025 20:40:23 +0000 (21:40 +0100)
Replace part of the code using ubifs_crc_node.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/io.c
fs/ubifs/recovery.c

index e0dfe6827d65bed6bcf0c7248d5025fdc0761b3b..6c6d6824277930f0480d3607d47db708c9fab15a 100644 (file)
@@ -327,8 +327,6 @@ out:
  */
 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);
 }
 
 /**
index f0d51dd21c9e13d5ba13e29f3caa703bc84e8b61..b36dc9b032f48d518c7a040252227935208abf0d 100644 (file)
@@ -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;