mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tyler Hicks <tyhicks@canonical.com>
To: "Jérémy Lefaure" <jeremy.lefaure@lse.epita.fr>
Cc: ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/18] ecryptfs: use ARRAY_SIZE
Date: Fri, 13 Oct 2017 21:31:40 -0400	[thread overview]
Message-ID: <3c5e2bb7-7c16-87cb-899f-8c9c322ce5da@canonical.com> (raw)
In-Reply-To: <20171001193101.8898-9-jeremy.lefaure@lse.epita.fr>


[-- Attachment #1.1: Type: text/plain, Size: 1898 bytes --]

On 10/01/2017 03:30 PM, 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>

Hey Jérémy - Thanks for the nice cleanup. I'll get it into 4.15.

Tyler

> ---
>  fs/ecryptfs/crypto.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 7acd57da4f14..2e78e851788e 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -36,6 +36,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/slab.h>
>  #include <asm/unaligned.h>
> +#include <linux/kernel.h>
>  #include "ecryptfs_kernel.h"
>  
>  #define DECRYPT		0
> @@ -884,8 +885,7 @@ static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat,
>  	u32 flags;
>  
>  	flags = get_unaligned_be32(page_virt);
> -	for (i = 0; i < ((sizeof(ecryptfs_flag_map)
> -			  / sizeof(struct ecryptfs_flag_map_elem))); i++)
> +	for (i = 0; i < ARRAY_SIZE(ecryptfs_flag_map); i++)
>  		if (flags & ecryptfs_flag_map[i].file_flag) {
>  			crypt_stat->flags |= ecryptfs_flag_map[i].local_flag;
>  		} else
> @@ -922,8 +922,7 @@ void ecryptfs_write_crypt_stat_flags(char *page_virt,
>  	u32 flags = 0;
>  	int i;
>  
> -	for (i = 0; i < ((sizeof(ecryptfs_flag_map)
> -			  / sizeof(struct ecryptfs_flag_map_elem))); i++)
> +	for (i = 0; i < ARRAY_SIZE(ecryptfs_flag_map); i++)
>  		if (crypt_stat->flags & ecryptfs_flag_map[i].local_flag)
>  			flags |= ecryptfs_flag_map[i].file_flag;
>  	/* Version is in top 8 bits of the 32-bit flag vector */
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2017-10-14  1:31 UTC|newest]

Thread overview: 51+ 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 ` [PATCH 01/18] sound: use ARRAY_SIZE Jérémy Lefaure
2017-10-02  4:16   ` Joe Perches
2017-10-03  1:12     ` Jérémy Lefaure
2017-10-03  7:03   ` Takashi Iwai
2017-10-01 19:30 ` [PATCH 02/18] tracing/filter: " Jérémy Lefaure
2017-10-04  1:05   ` Steven Rostedt
2017-10-01 19:30 ` [PATCH 03/18] media: " Jérémy Lefaure
2017-10-02 10:34   ` Michael Ira Krufky
2017-10-01 19:30 ` [PATCH 04/18] IB/mlx5: Use ARRAY_SIZE Jérémy Lefaure
2017-10-02  4:38   ` Leon Romanovsky
2017-10-01 19:30 ` [PATCH 05/18] net: use ARRAY_SIZE Jérémy Lefaure
2017-10-02 13:07   ` Andy Shevchenko
2017-10-03  1:22     ` Jérémy Lefaure
2017-10-03  8:09       ` Andy Shevchenko
2017-10-02 13:46   ` Kalle Valo
2017-10-03  1:23     ` Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 06/18] drm: " Jérémy Lefaure
2017-10-02  7:43   ` Jani Nikula
2017-10-02  8:27   ` Thierry Reding
2017-10-01 19:30 ` [PATCH 07/18] scsi: bfa: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 08/18] ecryptfs: " Jérémy Lefaure
2017-10-14  1:31   ` Tyler Hicks [this message]
2017-10-01 19:30 ` [PATCH 09/18] nfsd: " Jérémy Lefaure
2017-10-02 11:03   ` Jeff Layton
2017-10-01 19:30 ` [PATCH 10/18] orangefs: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 11/18] dm space map metadata: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 12/18] x86: " Jérémy Lefaure
2017-10-19 14:18   ` [tip:x86/cleanups] x86: Use ARRAY_SIZE tip-bot for Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 13/18] tpm: use ARRAY_SIZE Jérémy Lefaure
2017-10-04 12:14   ` Jarkko Sakkinen
2017-10-10 20:30     ` Jérémy Lefaure
2017-10-11 11:48       ` Jarkko Sakkinen
2017-10-01 19:30 ` [PATCH 14/18] ipmi: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 15/18] acpi: " Jérémy Lefaure
2017-10-02 12:27   ` Rafael J. Wysocki
2017-10-03  1:16     ` Jérémy Lefaure
2017-10-03 11:39       ` Rafael J. Wysocki
2017-10-03 12:34         ` [Devel] " Colin Ian King
2017-10-03 16:04           ` Rafael J. Wysocki
2017-10-03 16:38             ` Moore, Robert
2017-10-01 19:30 ` [PATCH 16/18] media: staging: atomisp: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 17/18] staging: rtl8723bs: " Jérémy Lefaure
2017-10-01 19:30 ` [PATCH 18/18] staging: rtlwifi: " Jérémy Lefaure
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=3c5e2bb7-7c16-87cb-899f-8c9c322ce5da@canonical.com \
    --to=tyhicks@canonical.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=jeremy.lefaure@lse.epita.fr \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®