MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _ql_verify

Function _ql_verify

app/redis-6.2.6/src/quicklist.c:1622–1703  ·  view source on GitHub ↗

Verify list metadata matches physical list contents. */

Source from the content-addressed store, hash-verified

1620
1621/* Verify list metadata matches physical list contents. */
1622static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count,
1623 uint32_t head_count, uint32_t tail_count) {
1624 int errors = 0;
1625
1626 ql_info(ql);
1627 if (len != ql->len) {
1628 yell("quicklist length wrong: expected %d, got %lu", len, ql->len);
1629 errors++;
1630 }
1631
1632 if (count != ql->count) {
1633 yell("quicklist count wrong: expected %d, got %lu", count, ql->count);
1634 errors++;
1635 }
1636
1637 int loopr = itrprintr(ql, 0);
1638 if (loopr != (int)ql->count) {
1639 yell("quicklist cached count not match actual count: expected %lu, got "
1640 "%d",
1641 ql->count, loopr);
1642 errors++;
1643 }
1644
1645 int rloopr = itrprintr_rev(ql, 0);
1646 if (loopr != rloopr) {
1647 yell("quicklist has different forward count than reverse count! "
1648 "Forward count is %d, reverse count is %d.",
1649 loopr, rloopr);
1650 errors++;
1651 }
1652
1653 if (ql->len == 0 && !errors) {
1654 return errors;
1655 }
1656
1657 if (ql->head && head_count != ql->head->count &&
1658 head_count != ziplistLen(ql->head->zl)) {
1659 yell("quicklist head count wrong: expected %d, "
1660 "got cached %d vs. actual %d",
1661 head_count, ql->head->count, ziplistLen(ql->head->zl));
1662 errors++;
1663 }
1664
1665 if (ql->tail && tail_count != ql->tail->count &&
1666 tail_count != ziplistLen(ql->tail->zl)) {
1667 yell("quicklist tail count wrong: expected %d, "
1668 "got cached %u vs. actual %d",
1669 tail_count, ql->tail->count, ziplistLen(ql->tail->zl));
1670 errors++;
1671 }
1672
1673 if (quicklistAllowsCompression(ql)) {
1674 quicklistNode *node = ql->head;
1675 unsigned int low_raw = ql->compress;
1676 unsigned int high_raw = ql->len - ql->compress;
1677
1678 for (unsigned int at = 0; at < ql->len; at++, node = node->next) {
1679 if (node && (at < low_raw || at >= high_raw)) {

Callers

nothing calls this directly

Calls 4

ql_infoFunction · 0.85
itrprintrFunction · 0.85
itrprintr_revFunction · 0.85
ziplistLenFunction · 0.85

Tested by

no test coverage detected