Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a133552a authored by Jérémy Lefaure's avatar Jérémy Lefaure Committed by J. Bruce Fields
Browse files

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: default avatarJérémy Lefaure <jeremy.lefaure@lse.epita.fr>
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent de766e57
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/nsproxy.h>
#include <linux/nsproxy.h>
#include <linux/sunrpc/addr.h>
#include <linux/sunrpc/addr.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>
#include <linux/kernel.h>


#include "state.h"
#include "state.h"
#include "netns.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)
int nfsd_fault_inject_init(void)
{
{
	unsigned int i;
	unsigned int i;
@@ -137,7 +136,7 @@ int nfsd_fault_inject_init(void)
	if (!debug_dir)
	if (!debug_dir)
		goto fail;
		goto fail;


	for (i = 0; i < NUM_INJECT_OPS; i++) {
	for (i = 0; i < ARRAY_SIZE(inject_ops); i++) {
		op = &inject_ops[i];
		op = &inject_ops[i];
		if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
		if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
			goto fail;
			goto fail;