From 8da81535be9de15a6e038a4cee2c0975050cab11 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Thu, 15 Jul 2004 22:51:51 -0700 Subject: [PATCH] [PATCH] hfs and hfsplus switched to use of ffs(3) instead of homegrown versions --- fs/hfs/btree.c | 7 ++----- fs/hfsplus/btree.c | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c index 3e620efdd476e..19f10cf9f6fb7 100644 --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -19,7 +19,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke struct hfs_btree_header_rec *head; struct address_space *mapping; struct page *page; - unsigned int shift, size; + unsigned int size; tree = kmalloc(sizeof(*tree), GFP_KERNEL); if (!tree) @@ -82,10 +82,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke goto fail_page; if (!tree->node_count) goto fail_page; - for (shift = 0; size >>= 1; shift += 1) - ; - tree->node_size_shift = shift; - + tree->node_size_shift = ffs(size) - 1; tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; kunmap(page); diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c index 84870a169fc72..b071364901025 100644 --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c @@ -22,7 +22,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) struct hfs_btree_header_rec *head; struct address_space *mapping; struct page *page; - unsigned int shift, size; + unsigned int size; tree = kmalloc(sizeof(*tree), GFP_KERNEL); if (!tree) @@ -69,9 +69,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id) goto fail_page; if (!tree->node_count) goto fail_page; - for (shift = 0; size >>= 1; shift += 1) - ; - tree->node_size_shift = shift; + tree->node_size_shift = ffs(size) - 1; tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; -- 2.53.0