Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Unified Diff: dm-bht.c

Issue 6742001: verity: handle trees with an odd node count correctly (Closed) Base URL: http://git.chromium.org/git/dm-verity.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dm-bht_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm-bht.c
diff --git a/dm-bht.c b/dm-bht.c
index dd57e12a0d467c26c3807248db84a290efa3e1b8..8a5e33f67b82f7763aaef44f72092d530901b21f 100644
--- a/dm-bht.c
+++ b/dm-bht.c
@@ -834,7 +834,6 @@ int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx)
struct dm_bht_level *child_level = level + 1;
struct dm_bht_entry *entry = level->entries;
struct dm_bht_entry *child = child_level->entries;
- unsigned int count = min(bht->node_count, child_level->count);
unsigned int i, j;
r = dm_bht_maybe_read_entries(bht, read_cb_ctx, depth,
@@ -845,6 +844,11 @@ int dm_bht_compute(struct dm_bht *bht, void *read_cb_ctx)
}
for (i = 0; i < level->count; i++, entry++) {
+ unsigned int count = bht->node_count;
+ if (i == (level->count - 1))
Will Drewry 2011/03/25 02:52:49 Could this just be: unsigned int count = child_lev
+ count = child_level->count % bht->node_count;
+ if (count == 0)
+ count = bht->node_count;
for (j = 0; j < count; j++, child++) {
u8 *block = child->nodes;
u8 *digest = dm_bht_node(bht, entry, j);
« no previous file with comments | « no previous file | dm-bht_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698