Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubifs: Simplify the code using ubifs_crc_node

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>

authored by

Xichao Zhao and committed by
Richard Weinberger
0288d5fe e3577061

+3 -10
+2 -7
fs/ubifs/io.c
··· 327 327 */ 328 328 void ubifs_pad(const struct ubifs_info *c, void *buf, int pad) 329 329 { 330 - uint32_t crc; 331 - 332 330 ubifs_assert(c, pad >= 0); 333 331 334 332 if (pad >= UBIFS_PAD_NODE_SZ) { ··· 341 343 ch->len = cpu_to_le32(UBIFS_PAD_NODE_SZ); 342 344 pad -= UBIFS_PAD_NODE_SZ; 343 345 pad_node->pad_len = cpu_to_le32(pad); 344 - crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8); 345 - ch->crc = cpu_to_le32(crc); 346 + ubifs_crc_node(buf, UBIFS_PAD_NODE_SZ); 346 347 memset(buf + UBIFS_PAD_NODE_SZ, 0, pad); 347 348 } else if (pad > 0) 348 349 /* Too little space, padding node won't fit */ ··· 466 469 */ 467 470 void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last) 468 471 { 469 - uint32_t crc; 470 472 struct ubifs_ch *ch = node; 471 473 unsigned long long sqnum = next_sqnum(c); 472 474 ··· 479 483 ch->group_type = UBIFS_IN_NODE_GROUP; 480 484 ch->sqnum = cpu_to_le64(sqnum); 481 485 ch->padding[0] = ch->padding[1] = 0; 482 - crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8); 483 - ch->crc = cpu_to_le32(crc); 486 + ubifs_crc_node(node, len); 484 487 } 485 488 486 489 /**
+1 -3
fs/ubifs/recovery.c
··· 1406 1406 union ubifs_key key; 1407 1407 int err, lnum, offs, len; 1408 1408 loff_t i_size; 1409 - uint32_t crc; 1410 1409 1411 1410 /* Locate the inode node LEB number and offset */ 1412 1411 ino_key_init(c, &key, e->inum); ··· 1427 1428 ino = c->sbuf + offs; 1428 1429 ino->size = cpu_to_le64(e->d_size); 1429 1430 len = le32_to_cpu(ino->ch.len); 1430 - crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8); 1431 - ino->ch.crc = cpu_to_le32(crc); 1431 + ubifs_crc_node((void *)ino, len); 1432 1432 /* Work out where data in the LEB ends and free space begins */ 1433 1433 p = c->sbuf; 1434 1434 len = c->leb_size - 1;