From: "Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>
To: "J. Bruce Fields" <bfields@fieldses.org>,
Jeff Layton <jlayton@poochiereds.net>
Cc: "Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 09/18] nfsd: use ARRAY_SIZE
Date: Sun, 1 Oct 2017 15:30:47 -0400 [thread overview]
Message-ID: <20171001193101.8898-10-jeremy.lefaure@lse.epita.fr> (raw)
In-Reply-To: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr>
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>
---
fs/nfsd/fault_inject.c | 5 ++---
1 file 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 @@
#include <linux/nsproxy.h>
#include <linux/sunrpc/addr.h>
#include <linux/uaccess.h>
+#include <linux/kernel.h>
#include "state.h"
#include "netns.h"
@@ -125,8 +126,6 @@ static struct nfsd_fault_inject_op inject_ops[] = {
},
};
-#define NUM_INJECT_OPS (sizeof(inject_ops)/sizeof(struct nfsd_fault_inject_op))
-
int nfsd_fault_inject_init(void)
{
unsigned int i;
@@ -137,7 +136,7 @@ int nfsd_fault_inject_init(void)
if (!debug_dir)
goto fail;
- for (i = 0; i < NUM_INJECT_OPS; i++) {
+ for (i = 0; i < ARRAY_SIZE(inject_ops); i++) {
op = &inject_ops[i];
if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
goto fail;
--
2.14.1
next prev parent reply other threads:[~2017-10-01 19:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-01 19:30 [PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure
2017-10-01 19:30 ` Jérémy Lefaure [this message]
2017-10-02 11:03 ` [PATCH 09/18] nfsd: use ARRAY_SIZE Jeff Layton
2017-10-01 22:01 ` [PATCH 00/18] use ARRAY_SIZE macro Tobin C. Harding
2017-10-02 0:52 ` Jérémy Lefaure
2017-10-02 5:35 ` Greg KH
2017-10-02 19:22 ` J. Bruce Fields
2017-10-03 1:33 ` Jérémy Lefaure
2017-10-05 17:57 ` J. Bruce Fields
2017-10-02 16:37 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171001193101.8898-10-jeremy.lefaure@lse.epita.fr \
--to=jeremy.lefaure@lse.epita.fr \
--cc=bfields@fieldses.org \
--cc=jlayton@poochiereds.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).