aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-08 05:29:58 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-30 03:19:07 -0400
commit66576833f5396af34c52160b16d7b8573199282a (patch)
tree557944b9b8088fab39cdf426be299300530ec79f /fs/ubifs
parentab87118d717467cbcd9648692c2a9708d55193bc (diff)
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>
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/gc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 27815bb91125..dafef3d195d3 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -127,8 +127,11 @@ int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
127 cond_resched(); 127 cond_resched();
128 sa = list_entry(a, struct ubifs_scan_node, list); 128 sa = list_entry(a, struct ubifs_scan_node, list);
129 sb = list_entry(b, struct ubifs_scan_node, list); 129 sb = list_entry(b, struct ubifs_scan_node, list);
130
130 ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY); 131 ubifs_assert(key_type(c, &sa->key) == UBIFS_DATA_KEY);
131 ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY); 132 ubifs_assert(key_type(c, &sb->key) == UBIFS_DATA_KEY);
133 ubifs_assert(sa->type == UBIFS_DATA_NODE);
134 ubifs_assert(sb->type == UBIFS_DATA_NODE);
132 135
133 inuma = key_inum(c, &sa->key); 136 inuma = key_inum(c, &sa->key);
134 inumb = key_inum(c, &sb->key); 137 inumb = key_inum(c, &sb->key);
@@ -164,6 +167,9 @@ int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
164 cond_resched(); 167 cond_resched();
165 sa = list_entry(a, struct ubifs_scan_node, list); 168 sa = list_entry(a, struct ubifs_scan_node, list);
166 sb = list_entry(b, struct ubifs_scan_node, list); 169 sb = list_entry(b, struct ubifs_scan_node, list);
170
171 ubifs_assert(key_type(c, &sa->key) != UBIFS_DATA_KEY &&
172 key_type(c, &sb->key) != UBIFS_DATA_KEY);
167 ubifs_assert(sa->type != UBIFS_DATA_NODE && 173 ubifs_assert(sa->type != UBIFS_DATA_NODE &&
168 sb->type != UBIFS_DATA_NODE); 174 sb->type != UBIFS_DATA_NODE);
169 175
@@ -176,10 +182,15 @@ int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
176 if (sb->type == UBIFS_INO_NODE) 182 if (sb->type == UBIFS_INO_NODE)
177 return 1; 183 return 1;
178 184
185 ubifs_assert(key_type(c, &sa->key) == UBIFS_DENT_KEY ||
186 key_type(c, &sa->key) == UBIFS_XENT_KEY);
187 ubifs_assert(key_type(c, &sb->key) == UBIFS_DENT_KEY ||
188 key_type(c, &sb->key) == UBIFS_XENT_KEY);
179 ubifs_assert(sa->type == UBIFS_DENT_NODE || 189 ubifs_assert(sa->type == UBIFS_DENT_NODE ||
180 sa->type == UBIFS_XENT_NODE); 190 sa->type == UBIFS_XENT_NODE);
181 ubifs_assert(sb->type == UBIFS_DENT_NODE || 191 ubifs_assert(sb->type == UBIFS_DENT_NODE ||
182 sb->type == UBIFS_XENT_NODE); 192 sb->type == UBIFS_XENT_NODE);
193
183 inuma = key_inum(c, &sa->key); 194 inuma = key_inum(c, &sa->key);
184 inumb = key_inum(c, &sb->key); 195 inumb = key_inum(c, &sb->key);
185 196