Skip to content

Commit 0288d5f

Browse files
Xichao Zhaorichardweinberger
authored andcommitted
ubifs: Simplify the code using ubifs_crc_node
Replace part of the code using ubifs_crc_node. Signed-off-by: Xichao Zhao <[email protected]> Reviewed-by: Zhihao Cheng <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent e357706 commit 0288d5f

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

fs/ubifs/io.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
327327
*/
328328
void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
329329
{
330-
uint32_t crc;
331-
332330
ubifs_assert(c, pad >= 0);
333331

334332
if (pad >= UBIFS_PAD_NODE_SZ) {
@@ -343,8 +341,7 @@ void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
343341
ch->len = cpu_to_le32(UBIFS_PAD_NODE_SZ);
344342
pad -= UBIFS_PAD_NODE_SZ;
345343
pad_node->pad_len = cpu_to_le32(pad);
346-
crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8);
347-
ch->crc = cpu_to_le32(crc);
344+
ubifs_crc_node(buf, UBIFS_PAD_NODE_SZ);
348345
memset(buf + UBIFS_PAD_NODE_SZ, 0, pad);
349346
} else if (pad > 0)
350347
/* 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)
469466
*/
470467
void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
471468
{
472-
uint32_t crc;
473469
struct ubifs_ch *ch = node;
474470
unsigned long long sqnum = next_sqnum(c);
475471

@@ -483,8 +479,7 @@ void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
483479
ch->group_type = UBIFS_IN_NODE_GROUP;
484480
ch->sqnum = cpu_to_le64(sqnum);
485481
ch->padding[0] = ch->padding[1] = 0;
486-
crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
487-
ch->crc = cpu_to_le32(crc);
482+
ubifs_crc_node(node, len);
488483
}
489484

490485
/**

fs/ubifs/recovery.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,6 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
14061406
union ubifs_key key;
14071407
int err, lnum, offs, len;
14081408
loff_t i_size;
1409-
uint32_t crc;
14101409

14111410
/* Locate the inode node LEB number and offset */
14121411
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)
14281427
ino = c->sbuf + offs;
14291428
ino->size = cpu_to_le64(e->d_size);
14301429
len = le32_to_cpu(ino->ch.len);
1431-
crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8);
1432-
ino->ch.crc = cpu_to_le32(crc);
1430+
ubifs_crc_node((void *)ino, len);
14331431
/* Work out where data in the LEB ends and free space begins */
14341432
p = c->sbuf;
14351433
len = c->leb_size - 1;

0 commit comments

Comments
 (0)