summaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lpt.c
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-07-12 07:01:57 -0400
committerRichard Weinberger <richard@nod.at>2018-08-14 18:25:21 -0400
commit6eb61d587f4515e4be5669eff383c0185009954f (patch)
treea5d3183e104338319152a888e0ff980c2546e6e1 /fs/ubifs/lpt.c
parent54169ddd382d461f7c01cc5a5182a4b4bc539489 (diff)
ubifs: Pass struct ubifs_info to ubifs_assert()
This allows us to have more context in ubifs_assert() and take different actions depending on the configuration. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r--fs/ubifs/lpt.c112
1 files changed, 57 insertions, 55 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index 8e99dad18880..31393370e334 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -225,21 +225,22 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs,
225 225
226/** 226/**
227 * pack_bits - pack bit fields end-to-end. 227 * pack_bits - pack bit fields end-to-end.
228 * @c: UBIFS file-system description object
228 * @addr: address at which to pack (passed and next address returned) 229 * @addr: address at which to pack (passed and next address returned)
229 * @pos: bit position at which to pack (passed and next position returned) 230 * @pos: bit position at which to pack (passed and next position returned)
230 * @val: value to pack 231 * @val: value to pack
231 * @nrbits: number of bits of value to pack (1-32) 232 * @nrbits: number of bits of value to pack (1-32)
232 */ 233 */
233static void pack_bits(uint8_t **addr, int *pos, uint32_t val, int nrbits) 234static void pack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, uint32_t val, int nrbits)
234{ 235{
235 uint8_t *p = *addr; 236 uint8_t *p = *addr;
236 int b = *pos; 237 int b = *pos;
237 238
238 ubifs_assert(nrbits > 0); 239 ubifs_assert(c, nrbits > 0);
239 ubifs_assert(nrbits <= 32); 240 ubifs_assert(c, nrbits <= 32);
240 ubifs_assert(*pos >= 0); 241 ubifs_assert(c, *pos >= 0);
241 ubifs_assert(*pos < 8); 242 ubifs_assert(c, *pos < 8);
242 ubifs_assert((val >> nrbits) == 0 || nrbits == 32); 243 ubifs_assert(c, (val >> nrbits) == 0 || nrbits == 32);
243 if (b) { 244 if (b) {
244 *p |= ((uint8_t)val) << b; 245 *p |= ((uint8_t)val) << b;
245 nrbits += b; 246 nrbits += b;
@@ -274,13 +275,14 @@ static void pack_bits(uint8_t **addr, int *pos, uint32_t val, int nrbits)
274 275
275/** 276/**
276 * ubifs_unpack_bits - unpack bit fields. 277 * ubifs_unpack_bits - unpack bit fields.
278 * @c: UBIFS file-system description object
277 * @addr: address at which to unpack (passed and next address returned) 279 * @addr: address at which to unpack (passed and next address returned)
278 * @pos: bit position at which to unpack (passed and next position returned) 280 * @pos: bit position at which to unpack (passed and next position returned)
279 * @nrbits: number of bits of value to unpack (1-32) 281 * @nrbits: number of bits of value to unpack (1-32)
280 * 282 *
281 * This functions returns the value unpacked. 283 * This functions returns the value unpacked.
282 */ 284 */
283uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits) 285uint32_t ubifs_unpack_bits(const struct ubifs_info *c, uint8_t **addr, int *pos, int nrbits)
284{ 286{
285 const int k = 32 - nrbits; 287 const int k = 32 - nrbits;
286 uint8_t *p = *addr; 288 uint8_t *p = *addr;
@@ -288,10 +290,10 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits)
288 uint32_t uninitialized_var(val); 290 uint32_t uninitialized_var(val);
289 const int bytes = (nrbits + b + 7) >> 3; 291 const int bytes = (nrbits + b + 7) >> 3;
290 292
291 ubifs_assert(nrbits > 0); 293 ubifs_assert(c, nrbits > 0);
292 ubifs_assert(nrbits <= 32); 294 ubifs_assert(c, nrbits <= 32);
293 ubifs_assert(*pos >= 0); 295 ubifs_assert(c, *pos >= 0);
294 ubifs_assert(*pos < 8); 296 ubifs_assert(c, *pos < 8);
295 if (b) { 297 if (b) {
296 switch (bytes) { 298 switch (bytes) {
297 case 2: 299 case 2:
@@ -337,7 +339,7 @@ uint32_t ubifs_unpack_bits(uint8_t **addr, int *pos, int nrbits)
337 p += nrbits >> 3; 339 p += nrbits >> 3;
338 *addr = p; 340 *addr = p;
339 *pos = b; 341 *pos = b;
340 ubifs_assert((val >> nrbits) == 0 || nrbits - b == 32); 342 ubifs_assert(c, (val >> nrbits) == 0 || nrbits - b == 32);
341 return val; 343 return val;
342} 344}
343 345
@@ -354,24 +356,24 @@ void ubifs_pack_pnode(struct ubifs_info *c, void *buf,
354 int i, pos = 0; 356 int i, pos = 0;
355 uint16_t crc; 357 uint16_t crc;
356 358
357 pack_bits(&addr, &pos, UBIFS_LPT_PNODE, UBIFS_LPT_TYPE_BITS); 359 pack_bits(c, &addr, &pos, UBIFS_LPT_PNODE, UBIFS_LPT_TYPE_BITS);
358 if (c->big_lpt) 360 if (c->big_lpt)
359 pack_bits(&addr, &pos, pnode->num, c->pcnt_bits); 361 pack_bits(c, &addr, &pos, pnode->num, c->pcnt_bits);
360 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 362 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
361 pack_bits(&addr, &pos, pnode->lprops[i].free >> 3, 363 pack_bits(c, &addr, &pos, pnode->lprops[i].free >> 3,
362 c->space_bits); 364 c->space_bits);
363 pack_bits(&addr, &pos, pnode->lprops[i].dirty >> 3, 365 pack_bits(c, &addr, &pos, pnode->lprops[i].dirty >> 3,
364 c->space_bits); 366 c->space_bits);
365 if (pnode->lprops[i].flags & LPROPS_INDEX) 367 if (pnode->lprops[i].flags & LPROPS_INDEX)
366 pack_bits(&addr, &pos, 1, 1); 368 pack_bits(c, &addr, &pos, 1, 1);
367 else 369 else
368 pack_bits(&addr, &pos, 0, 1); 370 pack_bits(c, &addr, &pos, 0, 1);
369 } 371 }
370 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, 372 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES,
371 c->pnode_sz - UBIFS_LPT_CRC_BYTES); 373 c->pnode_sz - UBIFS_LPT_CRC_BYTES);
372 addr = buf; 374 addr = buf;
373 pos = 0; 375 pos = 0;
374 pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); 376 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS);
375} 377}
376 378
377/** 379/**
@@ -387,23 +389,23 @@ void ubifs_pack_nnode(struct ubifs_info *c, void *buf,
387 int i, pos = 0; 389 int i, pos = 0;
388 uint16_t crc; 390 uint16_t crc;
389 391
390 pack_bits(&addr, &pos, UBIFS_LPT_NNODE, UBIFS_LPT_TYPE_BITS); 392 pack_bits(c, &addr, &pos, UBIFS_LPT_NNODE, UBIFS_LPT_TYPE_BITS);
391 if (c->big_lpt) 393 if (c->big_lpt)
392 pack_bits(&addr, &pos, nnode->num, c->pcnt_bits); 394 pack_bits(c, &addr, &pos, nnode->num, c->pcnt_bits);
393 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 395 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
394 int lnum = nnode->nbranch[i].lnum; 396 int lnum = nnode->nbranch[i].lnum;
395 397
396 if (lnum == 0) 398 if (lnum == 0)
397 lnum = c->lpt_last + 1; 399 lnum = c->lpt_last + 1;
398 pack_bits(&addr, &pos, lnum - c->lpt_first, c->lpt_lnum_bits); 400 pack_bits(c, &addr, &pos, lnum - c->lpt_first, c->lpt_lnum_bits);
399 pack_bits(&addr, &pos, nnode->nbranch[i].offs, 401 pack_bits(c, &addr, &pos, nnode->nbranch[i].offs,
400 c->lpt_offs_bits); 402 c->lpt_offs_bits);
401 } 403 }
402 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, 404 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES,
403 c->nnode_sz - UBIFS_LPT_CRC_BYTES); 405 c->nnode_sz - UBIFS_LPT_CRC_BYTES);
404 addr = buf; 406 addr = buf;
405 pos = 0; 407 pos = 0;
406 pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); 408 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS);
407} 409}
408 410
409/** 411/**
@@ -419,16 +421,16 @@ void ubifs_pack_ltab(struct ubifs_info *c, void *buf,
419 int i, pos = 0; 421 int i, pos = 0;
420 uint16_t crc; 422 uint16_t crc;
421 423
422 pack_bits(&addr, &pos, UBIFS_LPT_LTAB, UBIFS_LPT_TYPE_BITS); 424 pack_bits(c, &addr, &pos, UBIFS_LPT_LTAB, UBIFS_LPT_TYPE_BITS);
423 for (i = 0; i < c->lpt_lebs; i++) { 425 for (i = 0; i < c->lpt_lebs; i++) {
424 pack_bits(&addr, &pos, ltab[i].free, c->lpt_spc_bits); 426 pack_bits(c, &addr, &pos, ltab[i].free, c->lpt_spc_bits);
425 pack_bits(&addr, &pos, ltab[i].dirty, c->lpt_spc_bits); 427 pack_bits(c, &addr, &pos, ltab[i].dirty, c->lpt_spc_bits);
426 } 428 }
427 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, 429 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES,
428 c->ltab_sz - UBIFS_LPT_CRC_BYTES); 430 c->ltab_sz - UBIFS_LPT_CRC_BYTES);
429 addr = buf; 431 addr = buf;
430 pos = 0; 432 pos = 0;
431 pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); 433 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS);
432} 434}
433 435
434/** 436/**
@@ -443,14 +445,14 @@ void ubifs_pack_lsave(struct ubifs_info *c, void *buf, int *lsave)
443 int i, pos = 0; 445 int i, pos = 0;
444 uint16_t crc; 446 uint16_t crc;
445 447
446 pack_bits(&addr, &pos, UBIFS_LPT_LSAVE, UBIFS_LPT_TYPE_BITS); 448 pack_bits(c, &addr, &pos, UBIFS_LPT_LSAVE, UBIFS_LPT_TYPE_BITS);
447 for (i = 0; i < c->lsave_cnt; i++) 449 for (i = 0; i < c->lsave_cnt; i++)
448 pack_bits(&addr, &pos, lsave[i], c->lnum_bits); 450 pack_bits(c, &addr, &pos, lsave[i], c->lnum_bits);
449 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, 451 crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES,
450 c->lsave_sz - UBIFS_LPT_CRC_BYTES); 452 c->lsave_sz - UBIFS_LPT_CRC_BYTES);
451 addr = buf; 453 addr = buf;
452 pos = 0; 454 pos = 0;
453 pack_bits(&addr, &pos, crc, UBIFS_LPT_CRC_BITS); 455 pack_bits(c, &addr, &pos, crc, UBIFS_LPT_CRC_BITS);
454} 456}
455 457
456/** 458/**
@@ -465,7 +467,7 @@ void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty)
465 return; 467 return;
466 dbg_lp("LEB %d add %d to %d", 468 dbg_lp("LEB %d add %d to %d",
467 lnum, dirty, c->ltab[lnum - c->lpt_first].dirty); 469 lnum, dirty, c->ltab[lnum - c->lpt_first].dirty);
468 ubifs_assert(lnum >= c->lpt_first && lnum <= c->lpt_last); 470 ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last);
469 c->ltab[lnum - c->lpt_first].dirty += dirty; 471 c->ltab[lnum - c->lpt_first].dirty += dirty;
470} 472}
471 473
@@ -481,7 +483,7 @@ static void set_ltab(struct ubifs_info *c, int lnum, int free, int dirty)
481 dbg_lp("LEB %d free %d dirty %d to %d %d", 483 dbg_lp("LEB %d free %d dirty %d to %d %d",
482 lnum, c->ltab[lnum - c->lpt_first].free, 484 lnum, c->ltab[lnum - c->lpt_first].free,
483 c->ltab[lnum - c->lpt_first].dirty, free, dirty); 485 c->ltab[lnum - c->lpt_first].dirty, free, dirty);
484 ubifs_assert(lnum >= c->lpt_first && lnum <= c->lpt_last); 486 ubifs_assert(c, lnum >= c->lpt_first && lnum <= c->lpt_last);
485 c->ltab[lnum - c->lpt_first].free = free; 487 c->ltab[lnum - c->lpt_first].free = free;
486 c->ltab[lnum - c->lpt_first].dirty = dirty; 488 c->ltab[lnum - c->lpt_first].dirty = dirty;
487} 489}
@@ -639,7 +641,7 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
639 goto out; 641 goto out;
640 } 642 }
641 643
642 ubifs_assert(!c->ltab); 644 ubifs_assert(c, !c->ltab);
643 c->ltab = ltab; /* Needed by set_ltab */ 645 c->ltab = ltab; /* Needed by set_ltab */
644 646
645 /* Initialize LPT's own lprops */ 647 /* Initialize LPT's own lprops */
@@ -918,7 +920,7 @@ static int check_lpt_crc(const struct ubifs_info *c, void *buf, int len)
918 uint8_t *addr = buf; 920 uint8_t *addr = buf;
919 uint16_t crc, calc_crc; 921 uint16_t crc, calc_crc;
920 922
921 crc = ubifs_unpack_bits(&addr, &pos, UBIFS_LPT_CRC_BITS); 923 crc = ubifs_unpack_bits(c, &addr, &pos, UBIFS_LPT_CRC_BITS);
922 calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES, 924 calc_crc = crc16(-1, buf + UBIFS_LPT_CRC_BYTES,
923 len - UBIFS_LPT_CRC_BYTES); 925 len - UBIFS_LPT_CRC_BYTES);
924 if (crc != calc_crc) { 926 if (crc != calc_crc) {
@@ -944,7 +946,7 @@ static int check_lpt_type(const struct ubifs_info *c, uint8_t **addr,
944{ 946{
945 int node_type; 947 int node_type;
946 948
947 node_type = ubifs_unpack_bits(addr, pos, UBIFS_LPT_TYPE_BITS); 949 node_type = ubifs_unpack_bits(c, addr, pos, UBIFS_LPT_TYPE_BITS);
948 if (node_type != type) { 950 if (node_type != type) {
949 ubifs_err(c, "invalid type (%d) in LPT node type %d", 951 ubifs_err(c, "invalid type (%d) in LPT node type %d",
950 node_type, type); 952 node_type, type);
@@ -972,16 +974,16 @@ static int unpack_pnode(const struct ubifs_info *c, void *buf,
972 if (err) 974 if (err)
973 return err; 975 return err;
974 if (c->big_lpt) 976 if (c->big_lpt)
975 pnode->num = ubifs_unpack_bits(&addr, &pos, c->pcnt_bits); 977 pnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits);
976 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 978 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
977 struct ubifs_lprops * const lprops = &pnode->lprops[i]; 979 struct ubifs_lprops * const lprops = &pnode->lprops[i];
978 980
979 lprops->free = ubifs_unpack_bits(&addr, &pos, c->space_bits); 981 lprops->free = ubifs_unpack_bits(c, &addr, &pos, c->space_bits);
980 lprops->free <<= 3; 982 lprops->free <<= 3;
981 lprops->dirty = ubifs_unpack_bits(&addr, &pos, c->space_bits); 983 lprops->dirty = ubifs_unpack_bits(c, &addr, &pos, c->space_bits);
982 lprops->dirty <<= 3; 984 lprops->dirty <<= 3;
983 985
984 if (ubifs_unpack_bits(&addr, &pos, 1)) 986 if (ubifs_unpack_bits(c, &addr, &pos, 1))
985 lprops->flags = LPROPS_INDEX; 987 lprops->flags = LPROPS_INDEX;
986 else 988 else
987 lprops->flags = 0; 989 lprops->flags = 0;
@@ -1009,16 +1011,16 @@ int ubifs_unpack_nnode(const struct ubifs_info *c, void *buf,
1009 if (err) 1011 if (err)
1010 return err; 1012 return err;
1011 if (c->big_lpt) 1013 if (c->big_lpt)
1012 nnode->num = ubifs_unpack_bits(&addr, &pos, c->pcnt_bits); 1014 nnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits);
1013 for (i = 0; i < UBIFS_LPT_FANOUT; i++) { 1015 for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
1014 int lnum; 1016 int lnum;
1015 1017
1016 lnum = ubifs_unpack_bits(&addr, &pos, c->lpt_lnum_bits) + 1018 lnum = ubifs_unpack_bits(c, &addr, &pos, c->lpt_lnum_bits) +
1017 c->lpt_first; 1019 c->lpt_first;
1018 if (lnum == c->lpt_last + 1) 1020 if (lnum == c->lpt_last + 1)
1019 lnum = 0; 1021 lnum = 0;
1020 nnode->nbranch[i].lnum = lnum; 1022 nnode->nbranch[i].lnum = lnum;
1021 nnode->nbranch[i].offs = ubifs_unpack_bits(&addr, &pos, 1023 nnode->nbranch[i].offs = ubifs_unpack_bits(c, &addr, &pos,
1022 c->lpt_offs_bits); 1024 c->lpt_offs_bits);
1023 } 1025 }
1024 err = check_lpt_crc(c, buf, c->nnode_sz); 1026 err = check_lpt_crc(c, buf, c->nnode_sz);
@@ -1041,8 +1043,8 @@ static int unpack_ltab(const struct ubifs_info *c, void *buf)
1041 if (err) 1043 if (err)
1042 return err; 1044 return err;
1043 for (i = 0; i < c->lpt_lebs; i++) { 1045 for (i = 0; i < c->lpt_lebs; i++) {
1044 int free = ubifs_unpack_bits(&addr, &pos, c->lpt_spc_bits); 1046 int free = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits);
1045 int dirty = ubifs_unpack_bits(&addr, &pos, c->lpt_spc_bits); 1047 int dirty = ubifs_unpack_bits(c, &addr, &pos, c->lpt_spc_bits);
1046 1048
1047 if (free < 0 || free > c->leb_size || dirty < 0 || 1049 if (free < 0 || free > c->leb_size || dirty < 0 ||
1048 dirty > c->leb_size || free + dirty > c->leb_size) 1050 dirty > c->leb_size || free + dirty > c->leb_size)
@@ -1073,7 +1075,7 @@ static int unpack_lsave(const struct ubifs_info *c, void *buf)
1073 if (err) 1075 if (err)
1074 return err; 1076 return err;
1075 for (i = 0; i < c->lsave_cnt; i++) { 1077 for (i = 0; i < c->lsave_cnt; i++) {
1076 int lnum = ubifs_unpack_bits(&addr, &pos, c->lnum_bits); 1078 int lnum = ubifs_unpack_bits(c, &addr, &pos, c->lnum_bits);
1077 1079
1078 if (lnum < c->main_first || lnum >= c->leb_cnt) 1080 if (lnum < c->main_first || lnum >= c->leb_cnt)
1079 return -EINVAL; 1081 return -EINVAL;
@@ -1515,7 +1517,7 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c,
1515 branch->cnode->parent = n; 1517 branch->cnode->parent = n;
1516 } 1518 }
1517 1519
1518 ubifs_assert(!test_bit(OBSOLETE_CNODE, &nnode->flags)); 1520 ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &nnode->flags));
1519 __set_bit(OBSOLETE_CNODE, &nnode->flags); 1521 __set_bit(OBSOLETE_CNODE, &nnode->flags);
1520 1522
1521 c->dirty_nn_cnt += 1; 1523 c->dirty_nn_cnt += 1;
@@ -1558,7 +1560,7 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c,
1558 __clear_bit(COW_CNODE, &p->flags); 1560 __clear_bit(COW_CNODE, &p->flags);
1559 replace_cats(c, pnode, p); 1561 replace_cats(c, pnode, p);
1560 1562
1561 ubifs_assert(!test_bit(OBSOLETE_CNODE, &pnode->flags)); 1563 ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &pnode->flags));
1562 __set_bit(OBSOLETE_CNODE, &pnode->flags); 1564 __set_bit(OBSOLETE_CNODE, &pnode->flags);
1563 1565
1564 c->dirty_pn_cnt += 1; 1566 c->dirty_pn_cnt += 1;
@@ -1613,7 +1615,7 @@ struct ubifs_lprops *ubifs_lpt_lookup_dirty(struct ubifs_info *c, int lnum)
1613 dbg_lp("LEB %d, free %d, dirty %d, flags %d", lnum, 1615 dbg_lp("LEB %d, free %d, dirty %d, flags %d", lnum,
1614 pnode->lprops[iip].free, pnode->lprops[iip].dirty, 1616 pnode->lprops[iip].free, pnode->lprops[iip].dirty,
1615 pnode->lprops[iip].flags); 1617 pnode->lprops[iip].flags);
1616 ubifs_assert(test_bit(DIRTY_CNODE, &pnode->flags)); 1618 ubifs_assert(c, test_bit(DIRTY_CNODE, &pnode->flags));
1617 return &pnode->lprops[iip]; 1619 return &pnode->lprops[iip];
1618} 1620}
1619 1621
@@ -1889,9 +1891,9 @@ static struct ubifs_pnode *scan_get_pnode(struct ubifs_info *c,
1889 lprops->flags = ubifs_categorize_lprops(c, lprops); 1891 lprops->flags = ubifs_categorize_lprops(c, lprops);
1890 } 1892 }
1891 } else { 1893 } else {
1892 ubifs_assert(branch->lnum >= c->lpt_first && 1894 ubifs_assert(c, branch->lnum >= c->lpt_first &&
1893 branch->lnum <= c->lpt_last); 1895 branch->lnum <= c->lpt_last);
1894 ubifs_assert(branch->offs >= 0 && branch->offs < c->leb_size); 1896 ubifs_assert(c, branch->offs >= 0 && branch->offs < c->leb_size);
1895 err = ubifs_leb_read(c, branch->lnum, buf, branch->offs, 1897 err = ubifs_leb_read(c, branch->lnum, buf, branch->offs,
1896 c->pnode_sz, 1); 1898 c->pnode_sz, 1);
1897 if (err) 1899 if (err)
@@ -1935,8 +1937,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
1935 start_lnum = c->main_first; 1937 start_lnum = c->main_first;
1936 } 1938 }
1937 1939
1938 ubifs_assert(start_lnum >= c->main_first && start_lnum < c->leb_cnt); 1940 ubifs_assert(c, start_lnum >= c->main_first && start_lnum < c->leb_cnt);
1939 ubifs_assert(end_lnum >= c->main_first && end_lnum < c->leb_cnt); 1941 ubifs_assert(c, end_lnum >= c->main_first && end_lnum < c->leb_cnt);
1940 1942
1941 if (!c->nroot) { 1943 if (!c->nroot) {
1942 err = ubifs_read_nnode(c, NULL, 0); 1944 err = ubifs_read_nnode(c, NULL, 0);
@@ -2055,7 +2057,7 @@ again:
2055 iip = pnode->iip; 2057 iip = pnode->iip;
2056 while (1) { 2058 while (1) {
2057 h -= 1; 2059 h -= 1;
2058 ubifs_assert(h >= 0); 2060 ubifs_assert(c, h >= 0);
2059 nnode = path[h].ptr.nnode; 2061 nnode = path[h].ptr.nnode;
2060 if (iip + 1 < UBIFS_LPT_FANOUT) 2062 if (iip + 1 < UBIFS_LPT_FANOUT)
2061 break; 2063 break;
@@ -2234,7 +2236,7 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode,
2234 return 0; 2236 return 0;
2235 2237
2236 while (cnode) { 2238 while (cnode) {
2237 ubifs_assert(row >= 0); 2239 ubifs_assert(c, row >= 0);
2238 nnode = cnode->parent; 2240 nnode = cnode->parent;
2239 if (cnode->level) { 2241 if (cnode->level) {
2240 /* cnode is a nnode */ 2242 /* cnode is a nnode */