UBIFS: improve assertion in node comparison functions
Improve assertions in gc.c in the comparison functions for 'list_sort()': check key types _and_ node types. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
ab87118d71
commit
66576833f5
|
@ -127,8 +127,11 @@ int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
|
||||||
cond_resched();
|
cond_resched();
|
||||||
sa = list_entry(a, struct ubifs_scan_node, list);
|
sa = list_entry(a, struct ubifs_scan_node, list);
|
||||||
sb = list_entry(b, struct ubifs_scan_node, list);
|
sb = list_entry(b, struct ubifs_scan_node, list);
|
||||||
|
|
||||||
ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY);
|
ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY);
|
||||||
ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY);
|
ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY);
|
||||||
|
ubifs_assert(sa->type == UBIFS_DATA_NODE);
|
||||||
|
ubifs_assert(sb->type == UBIFS_DATA_NODE);
|
||||||
|
|
||||||
inuma = key_inum(c, &sa->key);
|
inuma = key_inum(c, &sa->key);
|
||||||
inumb = key_inum(c, &sb->key);
|
inumb = key_inum(c, &sb->key);
|
||||||
|
@ -164,6 +167,9 @@ int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
|
||||||
cond_resched();
|
cond_resched();
|
||||||
sa = list_entry(a, struct ubifs_scan_node, list);
|
sa = list_entry(a, struct ubifs_scan_node, list);
|
||||||
sb = list_entry(b, struct ubifs_scan_node, list);
|
sb = list_entry(b, struct ubifs_scan_node, list);
|
||||||
|
|
||||||
|
ubifs_assert(key_type(c, &sa->key) != UBIFS_DATA_KEY &&
|
||||||
|
key_type(c, &sb->key) != UBIFS_DATA_KEY);
|
||||||
ubifs_assert(sa->type != UBIFS_DATA_NODE &&
|
ubifs_assert(sa->type != UBIFS_DATA_NODE &&
|
||||||
sb->type != UBIFS_DATA_NODE);
|
sb->type != UBIFS_DATA_NODE);
|
||||||
|
|
||||||
|
@ -176,10 +182,15 @@ int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
|
||||||
if (sb->type == UBIFS_INO_NODE)
|
if (sb->type == UBIFS_INO_NODE)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
ubifs_assert(key_type(c, &sa->key) == UBIFS_DENT_KEY ||
|
||||||
|
key_type(c, &sa->key) == UBIFS_XENT_KEY);
|
||||||
|
ubifs_assert(key_type(c, &sb->key) == UBIFS_DENT_KEY ||
|
||||||
|
key_type(c, &sb->key) == UBIFS_XENT_KEY);
|
||||||
ubifs_assert(sa->type == UBIFS_DENT_NODE ||
|
ubifs_assert(sa->type == UBIFS_DENT_NODE ||
|
||||||
sa->type == UBIFS_XENT_NODE);
|
sa->type == UBIFS_XENT_NODE);
|
||||||
ubifs_assert(sb->type == UBIFS_DENT_NODE ||
|
ubifs_assert(sb->type == UBIFS_DENT_NODE ||
|
||||||
sb->type == UBIFS_XENT_NODE);
|
sb->type == UBIFS_XENT_NODE);
|
||||||
|
|
||||||
inuma = key_inum(c, &sa->key);
|
inuma = key_inum(c, &sa->key);
|
||||||
inumb = key_inum(c, &sb->key);
|
inumb = key_inum(c, &sb->key);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue