diff options
author | Joe Thornber | 2021-12-10 13:14:57 +0000 |
---|---|---|
committer | Mike Snitzer | 2022-01-04 12:59:55 -0500 |
commit | e36649b6483c68f9d4978785083972e72adbdbd2 (patch) | |
tree | 3671d42d52933ac7cbb4d9fc3101a1dcc4ac4bbb /drivers/md | |
parent | 851a8cd3f05bf21a0829f91dcab76d83313cd6ce (diff) |
dm btree spine: eliminate duplicate le32_to_cpu() in node_check()
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/persistent-data/dm-btree-spine.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c index 3d5abf30906c..e653458888a7 100644 --- a/drivers/md/persistent-data/dm-btree-spine.c +++ b/drivers/md/persistent-data/dm-btree-spine.c @@ -36,7 +36,7 @@ static int node_check(struct dm_block_validator *v, struct node_header *h = &n->header; size_t value_size; __le32 csum_disk; - uint32_t flags; + uint32_t flags, nr_entries, max_entries; if (dm_block_location(b) != le64_to_cpu(h->blocknr)) { DMERR_LIMIT("node_check failed: blocknr %llu != wanted %llu", @@ -53,15 +53,17 @@ static int node_check(struct dm_block_validator *v, return -EILSEQ; } + nr_entries = le32_to_cpu(h->nr_entries); + max_entries = le32_to_cpu(h->max_entries); value_size = le32_to_cpu(h->value_size); if (sizeof(struct node_header) + - (sizeof(__le64) + value_size) * le32_to_cpu(h->max_entries) > block_size) { + (sizeof(__le64) + value_size) * max_entries > block_size) { DMERR_LIMIT("node_check failed: max_entries too large"); return -EILSEQ; } - if (le32_to_cpu(h->nr_entries) > le32_to_cpu(h->max_entries)) { + if (nr_entries > max_entries) { DMERR_LIMIT("node_check failed: too many entries"); return -EILSEQ; } |