ubifs: remove unnecessary check in ubifs_log_start_commit
A message that is not in the archive (sent off-list or not yet received): [email protected]
Richard Weinberger
maintainerAm Dienstag, 21. August 2018, 08:57:44 CEST schrieb [email protected]:
Quoted 20 lines
Hi Richard,
In
ubifs_log_start_commit, the value ofc->lhead_offsis zero or set to zero by code bellow
409 /* Switch to the next log LEB */
410 if (c->lhead_offs) {411 c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum); 412 ubifs_assert(c->lhead_lnum != c->ltail_lnum); 413 c->lhead_offs = 0;414 }
The value of 'len' can not exceed '
max_len' which assigned value by code bellow
370max_len=UBIFS_CS_NODE_SZ+c->jhead_cnt*UBIFS_REF_NODE_SZ;So, the value of
c->lhead_offscannot exceed 'max_len'
429c->lhead_offs+= len;
430 if (c->lhead_offs==c->leb_size) {
431c->lhead_lnum=ubifs_next_log_lnum(c, c->lhead_lnum);
432c->lhead_offs= 0;
433 }
Quoted 4 lines
Usually, the size of PEB is between 64KB and 256KB, and in UBIFS, the value of
c->lhead_offsfar less thanUBIFS_BLOCK_SIZEwhich equal to 4096. So I think the value ofc->lhead_offsfar less thanc->leb_size, the check in line 430 seem never to be true.
Okay, now it makes sense.
But what has this do to with UBIFS_BLOCK_SIZE?
Anyway, your patch description needs to be more detailed. What you explained to me right now needs to go in the commit message. Then people can understand why the check is not needed. For the sake of paranoia and debug-ability, please also add a ubifs_assert(c->lhead_offs < c->leb_size);.
Thanks,
//richard