aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Lefaure <jeremy.lefaure@lse.epita.fr>2017-10-01 15:30:47 -0400
committerJ. Bruce Fields <bfields@redhat.com>2017-10-05 13:56:39 -0400
commita133552a0049aa2ff92f83dbe8d5185485b538c4 (patch)
tree53fd16800d897e36750219984ce2523a53a738e2
parentde766e570413bd0484af0b580299b495ada625c3 (diff)
nfsd: 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> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/fault_inject.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 34c1c449fddf..3ec72c931ac5 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -11,6 +11,7 @@
11#include <linux/nsproxy.h> 11#include <linux/nsproxy.h>
12#include <linux/sunrpc/addr.h> 12#include <linux/sunrpc/addr.h>
13#include <linux/uaccess.h> 13#include <linux/uaccess.h>
14#include <linux/kernel.h>
14 15
15#include "state.h" 16#include "state.h"
16#include "netns.h" 17#include "netns.h"
@@ -125,8 +126,6 @@ static struct nfsd_fault_inject_op inject_ops[] = {
125 }, 126 },
126}; 127};
127 128
128#define NUM_INJECT_OPS (sizeof(inject_ops)/sizeof(struct nfsd_fault_inject_op))
129
130int nfsd_fault_inject_init(void) 129int nfsd_fault_inject_init(void)
131{ 130{
132 unsigned int i; 131 unsigned int i;
@@ -137,7 +136,7 @@ int nfsd_fault_inject_init(void)
137 if (!debug_dir) 136 if (!debug_dir)
138 goto fail; 137 goto fail;
139 138
140 for (i = 0; i < NUM_INJECT_OPS; i++) { 139 for (i = 0; i < ARRAY_SIZE(inject_ops); i++) {
141 op = &inject_ops[i]; 140 op = &inject_ops[i];
142 if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd)) 141 if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
143 goto fail; 142 goto fail;