• Liu Song's avatar
    ubifs: remove unnecessary check in ubifs_log_start_commit · 8ba0a2ab
    Liu Song authored
    In ubifs_log_start_commit, the value of c->lhead_offs is zero or set
    to zero by code bellow.
    
    	/* Switch to the next log LEB */
    	if (c->lhead_offs) {
    		c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
    		ubifs_assert(c->lhead_lnum != c->ltail_lnum);
    		c->lhead_offs = 0;
    	}
    
    The value of 'len' can not exceed 'max_len' which assigned value by
    code bellow.
    
    	max_len = UBIFS_CS_NODE_SZ + c->jhead_cnt * UBIFS_REF_NODE_SZ;
    
    The value of c->lhead_offs changed by code bellow and cannot exceed
    'max_len'.
    
    	c->lhead_offs += len;
    	if (c->lhead_offs == c->leb_size) {
    		c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
    		c->lhead_offs = 0;
    	}
    
    Usually, the size of PEB is between 64KB and 256KB. So the value of
    c->lhead_offs is far less than c->leb_size. The check
    'if (c->lhead_offs == c->leb_size)' could never to be true.
    Signed-off-by: default avatarLiu Song <liu.song11@zte.com.cn>
    Reviewed-by: default avatarJiang Biao <jiang.biao2@zte.com.cn>
    Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
    8ba0a2ab
log.c 19.2 KB