lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c5e2bb7-7c16-87cb-899f-8c9c322ce5da@canonical.com>
Date:   Fri, 13 Oct 2017 21:31:40 -0400
From:   Tyler Hicks <tyhicks@...onical.com>
To:     Jérémy Lefaure <jeremy.lefaure@....epita.fr>
Cc:     ecryptfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 08/18] ecryptfs: use ARRAY_SIZE

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@....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 */
> 




Download attachment "signature.asc" of type "application/pgp-signature" (802 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ