diff options
author | Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> | 2017-10-01 15:30:49 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-11-10 15:44:52 -0500 |
commit | fbc61291d7da41ec19f339311297f59213165227 (patch) | |
tree | 57d695fa21a87bcb9cb41fd80780d1065daa1b28 /drivers/md/persistent-data | |
parent | 98d82f48f1983ceef5c8d2f6c87bfee2918790ee (diff) |
dm space map metadata: use ARRAY_SIZE
Using the ARRAY_SIZE macro improves the readability of the code.
Found with Coccinelle with the following semantic patch:
@r depends on (org || report)@
type T;
T[] E;
position p;
@@
(
(sizeof(E)@p /sizeof(*E))
|
(sizeof(E)@p /sizeof(E[...]))
|
(sizeof(E)@p /sizeof(T))
)
Signed-off-by: Jérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/persistent-data')
-rw-r--r-- | drivers/md/persistent-data/dm-space-map-metadata.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c index 4aed69d9dd17..aec449243966 100644 --- a/drivers/md/persistent-data/dm-space-map-metadata.c +++ b/drivers/md/persistent-data/dm-space-map-metadata.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/device-mapper.h> | 13 | #include <linux/device-mapper.h> |
14 | #include <linux/kernel.h> | ||
14 | 15 | ||
15 | #define DM_MSG_PREFIX "space map metadata" | 16 | #define DM_MSG_PREFIX "space map metadata" |
16 | 17 | ||
@@ -111,7 +112,7 @@ static bool brb_empty(struct bop_ring_buffer *brb) | |||
111 | static unsigned brb_next(struct bop_ring_buffer *brb, unsigned old) | 112 | static unsigned brb_next(struct bop_ring_buffer *brb, unsigned old) |
112 | { | 113 | { |
113 | unsigned r = old + 1; | 114 | unsigned r = old + 1; |
114 | return (r >= (sizeof(brb->bops) / sizeof(*brb->bops))) ? 0 : r; | 115 | return r >= ARRAY_SIZE(brb->bops) ? 0 : r; |
115 | } | 116 | } |
116 | 117 | ||
117 | static int brb_push(struct bop_ring_buffer *brb, | 118 | static int brb_push(struct bop_ring_buffer *brb, |