Commit | Line | Data |
---|---|---|
34e49164 C |
1 | // From: vignesh babu <vignesh.babu@wipro.com> |
2 | // Subject: [KJ] [PATCH]is_power_of_2-ntfs | |
3 | // To: aia21@cantab.net | |
4 | // Cc: linux-ntfs-dev@lists.sourceforge.net, | |
5 | // Kernel Janitors List <kernel-janitors@lists.osdl.org>, | |
6 | // linux-kernel <linux-kernel@vger.kernel.org> | |
7 | // Date: Thu, 14 Jun 2007 13:39:04 +0530 | |
8 | // Organization: WIPRO Technologies | |
9 | // Reply-To: vignesh.babu@wipro.com | |
10 | // | |
11 | // | |
12 | // Replacing (n & (n-1)) in the context of power of 2 checks | |
13 | // with is_power_of_2 | |
14 | // | |
15 | // Signed-off-by: vignesh babu <vignesh.babu@wipro.com> | |
16 | // --- | |
17 | // diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c | |
18 | // index b532a73..8152f79 100644 | |
19 | // --- a/fs/ntfs/inode.c | |
20 | // +++ b/fs/ntfs/inode.c | |
21 | // @@ -27,6 +27,7 @@ | |
22 | // #include <linux/pagemap.h> | |
23 | // #include <linux/quotaops.h> | |
24 | // #include <linux/slab.h> | |
25 | // +#include <linux/log2.h> | |
26 | // | |
27 | // #include "aops.h" | |
28 | // #include "attrib.h" | |
29 | // @@ -1574,7 +1575,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) | |
30 | // ntfs_debug("Index collation rule is 0x%x.", | |
31 | // le32_to_cpu(ir->collation_rule)); | |
32 | // ni->itype.index.block_size = le32_to_cpu(ir->index_block_size); | |
33 | // - if (ni->itype.index.block_size & (ni->itype.index.block_size - 1)) { | |
34 | // + if (!is_power_of_2(ni->itype.index.block_size)) { | |
35 | // ntfs_error(vi->i_sb, "Index block size (%u) is not a power of " | |
36 | // "two.", ni->itype.index.block_size); | |
37 | ||
38 | ||
39 | // how deal with extra '()' | |
40 | ||
41 | // - while ((big_pow2 & (big_pow2 - 1)) != 0) | |
42 | // + while (!is_power_of_2(big_pow2)) | |
43 | // | |
44 | // | |
45 | // - if (ubi->min_io_size == 0 || | |
46 | // - (ubi->min_io_size & (ubi->min_io_size - 1))) { | |
47 | // + if (!is_power_of_2(ubi->min_io_size)) { | |
48 | // | |
49 | // - if ((arg & (arg-1)) != 0 || arg < 1) { | |
50 | // + if (!is_power_of_2(arg)) { | |
51 | // | |
52 | // | |
53 | // // do something general for those != 0 ? always redundant ? | |
54 | // - if (bsize < 512 || bsize > 4096 || (bsize & (bsize - 1)) != 0) | |
55 | // + if (bsize < 512 || bsize > 4096 || !is_power_of_2(bsize)) | |
56 | // | |
57 | // - if (!bits || (bits & (bits - 1))) | |
58 | // + if (!is_power_of_2(bits)) | |
59 | // | |
60 | // | |
61 | // - J_ASSERT ((hash_size & (hash_size-1)) == 0); | |
62 | // + J_ASSERT (is_power_of_2(hash_size)); | |
63 | // | |
64 | // - if ((new_size & (new_size - 1)) != 0) { | |
65 | // + if (!is_power_of_2(new_size)){ | |
66 | // | |
67 | // #include "xfs_quota.h" | |
68 | // #include "xfs_acl.h" | |
69 | // | |
70 | // +#include <linux/log2.h> | |
71 | // | |
72 | // | |
73 | // - return !(size % (PAGE_SIZE >> 9) || (size & (size - 1)) || | |
74 | // + return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) || | |
75 | ||
76 | ||
77 | ||
78 | // script found on KJ: | |
79 | // grep -e "([^\(\)]+) ?\& ?\(\1 ?- ?1\)" | |
80 | ||
81 | ||
82 | @ rule1 @ | |
83 | expression n; | |
84 | @@ | |
85 | ||
86 | - n & (n-1) | |
87 | + !is_power_of_2(n) | |
88 | ||
89 | @ rule2 depends on rule1 @ | |
90 | @@ | |
91 | ||
92 | #include <linux/...> | |
93 | + #include <linux/log2.h> |