UBIFS: do not use key type in list_sort

In comparison function for 'list_sort()' we use key type to distinguish between
node types. However, we have a bit simper way to detect node type -
'snod->type'. This more logical to use, comparing to decoding key types. Also
allows to get rid of 2 local variables.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
Artem Bityutskiy 2010-08-08 12:25:33 +03:00
parent 44ec83b8bd
commit ab87118d71
1 changed files with 9 additions and 9 deletions

View File

@ -157,7 +157,6 @@ int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
*/ */
int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b) int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
{ {
int typea, typeb;
ino_t inuma, inumb; ino_t inuma, inumb;
struct ubifs_info *c = priv; struct ubifs_info *c = priv;
struct ubifs_scan_node *sa, *sb; struct ubifs_scan_node *sa, *sb;
@ -165,21 +164,22 @@ 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);
typea = key_type(c, &sa->key); ubifs_assert(sa->type != UBIFS_DATA_NODE &&
typeb = key_type(c, &sb->key); sb->type != UBIFS_DATA_NODE);
ubifs_assert(typea != UBIFS_DATA_KEY && typeb != UBIFS_DATA_KEY);
/* Inodes go before directory entries */ /* Inodes go before directory entries */
if (typea == UBIFS_INO_KEY) { if (sa->type == UBIFS_INO_NODE) {
if (typeb == UBIFS_INO_KEY) if (sb->type == UBIFS_INO_NODE)
return sb->len - sa->len; return sb->len - sa->len;
return -1; return -1;
} }
if (typeb == UBIFS_INO_KEY) if (sb->type == UBIFS_INO_NODE)
return 1; return 1;
ubifs_assert(typea == UBIFS_DENT_KEY || typea == UBIFS_XENT_KEY); ubifs_assert(sa->type == UBIFS_DENT_NODE ||
ubifs_assert(typeb == UBIFS_DENT_KEY || typeb == UBIFS_XENT_KEY); sa->type == UBIFS_XENT_NODE);
ubifs_assert(sb->type == UBIFS_DENT_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);