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] [day] [month] [year] [list]
Message-ID: <8937190.oVYW8tRbo1@sifl>
Date:	Tue, 17 Jun 2014 17:40:17 -0400
From:	Paul Moore <paul@...l-moore.com>
To:	Himangi Saraogi <himangi774@...il.com>
Cc:	Stephen Smalley <sds@...ho.nsa.gov>,
	Eric Paris <eparis@...isplace.org>,
	James Morris <james.l.morris@...cle.com>,
	selinux@...ho.nsa.gov, linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org, julia.lawall@...6.fr
Subject: Re: [PATCH] SELinux: use ARRAY_SIZE

On Tuesday, June 17, 2014 01:41:05 AM Himangi Saraogi wrote:
> ARRAY_SIZE is more concise to use when the size of an array is divided
> by the size of its type or the size of its first element.
> 
> The Coccinelle semantic patch that makes this change is as follows:
> 
> // <smpl>
> @@
> type T;
> T[] E;
> @@
> 
> - (sizeof(E)/sizeof(E[...]))
> + ARRAY_SIZE(E)
> // </smpl>
> 
> Signed-off-by: Himangi Saraogi <himangi774@...il.com>
> ---
>  security/selinux/ss/policydb.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks.

> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index 9c5cdc2..56eb65f 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -2608,7 +2608,7 @@ static int mls_write_range_helper(struct mls_range *r,
> void *fp) if (!eq)
>  		buf[2] = cpu_to_le32(r->level[1].sens);
> 
> -	BUG_ON(items > (sizeof(buf)/sizeof(buf[0])));
> +	BUG_ON(items > ARRAY_SIZE(buf));
> 
>  	rc = put_entry(buf, sizeof(u32), items, fp);
>  	if (rc)
> @@ -2990,7 +2990,7 @@ static int role_write(void *vkey, void *datum, void
> *ptr) if (p->policyvers >= POLICYDB_VERSION_BOUNDARY)
>  		buf[items++] = cpu_to_le32(role->bounds);
> 
> -	BUG_ON(items > (sizeof(buf)/sizeof(buf[0])));
> +	BUG_ON(items > ARRAY_SIZE(buf));
> 
>  	rc = put_entry(buf, sizeof(u32), items, fp);
>  	if (rc)
> @@ -3040,7 +3040,7 @@ static int type_write(void *vkey, void *datum, void
> *ptr) } else {
>  		buf[items++] = cpu_to_le32(typdatum->primary);
>  	}
> -	BUG_ON(items > (sizeof(buf) / sizeof(buf[0])));
> +	BUG_ON(items > ARRAY_SIZE(buf));
>  	rc = put_entry(buf, sizeof(u32), items, fp);
>  	if (rc)
>  		return rc;
> @@ -3069,7 +3069,7 @@ static int user_write(void *vkey, void *datum, void
> *ptr) buf[items++] = cpu_to_le32(usrdatum->value);
>  	if (p->policyvers >= POLICYDB_VERSION_BOUNDARY)
>  		buf[items++] = cpu_to_le32(usrdatum->bounds);
> -	BUG_ON(items > (sizeof(buf) / sizeof(buf[0])));
> +	BUG_ON(items > ARRAY_SIZE(buf));
>  	rc = put_entry(buf, sizeof(u32), items, fp);
>  	if (rc)
>  		return rc;

-- 
paul moore
www.paul-moore.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ