mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Himangi Saraogi <himangi774@gmail.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	Eric Paris <eparis@parisplace.org>,
	James Morris <james.l.morris@oracle.com>,
	selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, julia.lawall@lip6.fr
Subject: Re: [PATCH] SELinux: use ARRAY_SIZE
Date: Tue, 17 Jun 2014 17:40:17 -0400	[thread overview]
Message-ID: <8937190.oVYW8tRbo1@sifl> (raw)
In-Reply-To: <20140616201104.GA18288@himangi-Dell>

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@gmail.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


      reply	other threads:[~2014-06-17 21:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 20:11 Himangi Saraogi
2014-06-17 21:40 ` Paul Moore [this message]

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=8937190.oVYW8tRbo1@sifl \
    --to=paul@paul-moore.com \
    --cc=eparis@parisplace.org \
    --cc=himangi774@gmail.com \
    --cc=james.l.morris@oracle.com \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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®