Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1743120

Re: [PATCH 09/18] nfsd: use ARRAY_SIZE

From Jeff Layton <jlayton@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 09/18] nfsd: use ARRAY_SIZE
Date 2017-10-02 13:10 +0200
Message-ID <uw6LL-6zz-3@gated-at.bofh.it> (permalink)
References <uvSfL-67y-3@gated-at.bofh.it> <uvSfN-67y-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, 2017-10-01 at 15:30 -0400, Jérémy Lefaure wrote:
> 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;

Reviewed-by: Jeff Layton <jlayton@redhat.com>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 04/18] IB/mlx5: Use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 12/18] x86: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 02/18] tracing/filter: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 16/18] media: staging: atomisp: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 06/18] drm: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
    Re: [PATCH 06/18] drm: use ARRAY_SIZE Jani Nikula <jani.nikula@linux.intel.com> - 2017-10-02 09:50 +0200
    Re: [PATCH 06/18] drm: use ARRAY_SIZE Thierry Reding <thierry.reding@gmail.com> - 2017-10-02 10:30 +0200
  [PATCH 18/18] staging: rtlwifi: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 15/18] acpi: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
    Re: [PATCH 15/18] acpi: use ARRAY_SIZE "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-10-02 14:40 +0200
  [PATCH 01/18] sound: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
    Re: [PATCH 01/18] sound: use ARRAY_SIZE Joe Perches <joe@perches.com> - 2017-10-02 06:20 +0200
  [PATCH 09/18] nfsd: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
    Re: [PATCH 09/18] nfsd: use ARRAY_SIZE Jeff Layton <jlayton@redhat.com> - 2017-10-02 13:10 +0200
  [PATCH 08/18] ecryptfs: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 03/18] media: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
    Re: [PATCH 03/18] media: use ARRAY_SIZE Michael Ira Krufky <mkrufky@linuxtv.org> - 2017-10-02 12:40 +0200
  [PATCH 14/18] ipmi: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 07/18] scsi: bfa: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 17/18] staging: rtl8723bs: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 10/18] orangefs: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 13/18] tpm: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  [PATCH 11/18] dm space map metadata: use ARRAY_SIZE Jérémy Lefaure          <jeremy.lefaure@lse.epita.fr> - 2017-10-01 21:40 +0200
  Re: [PATCH 00/18] use ARRAY_SIZE macro "Tobin C. Harding" <me@tobin.cc> - 2017-10-02 00:10 +0200
    Re: [PATCH 00/18] use ARRAY_SIZE macro Jérémy Lefaure <jeremy.lefaure@lse.epita.fr> - 2017-10-02 03:00 +0200
      Re: [PATCH 00/18] use ARRAY_SIZE macro Greg KH <greg@kroah.com> - 2017-10-02 07:40 +0200
      Re: [PATCH 00/18] use ARRAY_SIZE macro Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-10-02 22:50 +0200
  Re: [PATCH 05/18] net: use ARRAY_SIZE Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-10-02 15:10 +0200

csiph-web