diff options
author | Byongho Lee <bhlee.kernel@gmail.com> | 2015-10-08 07:49:34 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-10-21 12:28:48 -0400 |
commit | 619ed39242d901339c09faa1b52dad47b0476f6f (patch) | |
tree | af5d5995c679a1d338f4e78867b9c848e98bc126 | |
parent | 8cd1e73111f95ca915f37ed534bbfbdf24fc1ca8 (diff) |
btrfs: cleanup iterating over prop_handlers array
This patch eliminates the last item of prop_handlers array which is used
to check end of array and instead uses ARRAY_SIZE macro.
Though this is a very tiny optimization, using ARRAY_SIZE macro is a
good practice to iterate array.
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/props.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index dca137b04095..f9e60231f685 100644 --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c | |||
@@ -49,18 +49,16 @@ static struct prop_handler prop_handlers[] = { | |||
49 | .extract = prop_compression_extract, | 49 | .extract = prop_compression_extract, |
50 | .inheritable = 1 | 50 | .inheritable = 1 |
51 | }, | 51 | }, |
52 | { | ||
53 | .xattr_name = NULL | ||
54 | } | ||
55 | }; | 52 | }; |
56 | 53 | ||
57 | void __init btrfs_props_init(void) | 54 | void __init btrfs_props_init(void) |
58 | { | 55 | { |
59 | struct prop_handler *p; | 56 | int i; |
60 | 57 | ||
61 | hash_init(prop_handlers_ht); | 58 | hash_init(prop_handlers_ht); |
62 | 59 | ||
63 | for (p = &prop_handlers[0]; p->xattr_name; p++) { | 60 | for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) { |
61 | struct prop_handler *p = &prop_handlers[i]; | ||
64 | u64 h = btrfs_name_hash(p->xattr_name, strlen(p->xattr_name)); | 62 | u64 h = btrfs_name_hash(p->xattr_name, strlen(p->xattr_name)); |
65 | 63 | ||
66 | hash_add(prop_handlers_ht, &p->node, h); | 64 | hash_add(prop_handlers_ht, &p->node, h); |
@@ -301,15 +299,16 @@ static int inherit_props(struct btrfs_trans_handle *trans, | |||
301 | struct inode *inode, | 299 | struct inode *inode, |
302 | struct inode *parent) | 300 | struct inode *parent) |
303 | { | 301 | { |
304 | const struct prop_handler *h; | ||
305 | struct btrfs_root *root = BTRFS_I(inode)->root; | 302 | struct btrfs_root *root = BTRFS_I(inode)->root; |
306 | int ret; | 303 | int ret; |
304 | int i; | ||
307 | 305 | ||
308 | if (!test_bit(BTRFS_INODE_HAS_PROPS, | 306 | if (!test_bit(BTRFS_INODE_HAS_PROPS, |
309 | &BTRFS_I(parent)->runtime_flags)) | 307 | &BTRFS_I(parent)->runtime_flags)) |
310 | return 0; | 308 | return 0; |
311 | 309 | ||
312 | for (h = &prop_handlers[0]; h->xattr_name; h++) { | 310 | for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) { |
311 | const struct prop_handler *h = &prop_handlers[i]; | ||
313 | const char *value; | 312 | const char *value; |
314 | u64 num_bytes; | 313 | u64 num_bytes; |
315 | 314 | ||