aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-06-16 16:11:05 -0400
committerPaul Moore <pmoore@redhat.com>2014-06-17 17:36:02 -0400
commit5c7001b84be55917a99c35ce96df7e67b3c40cea (patch)
tree39cba69c6ae4d9dd5d246a7510b61b3fa360d92b /security
parentaa65506f198c482b52ba6592c0023eca8b4bf8bd (diff)
SELinux: use ARRAY_SIZE
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> Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/ss/policydb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 9c5cdc2caaef..56eb65f67cb1 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)
2608 if (!eq) 2608 if (!eq)
2609 buf[2] = cpu_to_le32(r->level[1].sens); 2609 buf[2] = cpu_to_le32(r->level[1].sens);
2610 2610
2611 BUG_ON(items > (sizeof(buf)/sizeof(buf[0]))); 2611 BUG_ON(items > ARRAY_SIZE(buf));
2612 2612
2613 rc = put_entry(buf, sizeof(u32), items, fp); 2613 rc = put_entry(buf, sizeof(u32), items, fp);
2614 if (rc) 2614 if (rc)
@@ -2990,7 +2990,7 @@ static int role_write(void *vkey, void *datum, void *ptr)
2990 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) 2990 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY)
2991 buf[items++] = cpu_to_le32(role->bounds); 2991 buf[items++] = cpu_to_le32(role->bounds);
2992 2992
2993 BUG_ON(items > (sizeof(buf)/sizeof(buf[0]))); 2993 BUG_ON(items > ARRAY_SIZE(buf));
2994 2994
2995 rc = put_entry(buf, sizeof(u32), items, fp); 2995 rc = put_entry(buf, sizeof(u32), items, fp);
2996 if (rc) 2996 if (rc)
@@ -3040,7 +3040,7 @@ static int type_write(void *vkey, void *datum, void *ptr)
3040 } else { 3040 } else {
3041 buf[items++] = cpu_to_le32(typdatum->primary); 3041 buf[items++] = cpu_to_le32(typdatum->primary);
3042 } 3042 }
3043 BUG_ON(items > (sizeof(buf) / sizeof(buf[0]))); 3043 BUG_ON(items > ARRAY_SIZE(buf));
3044 rc = put_entry(buf, sizeof(u32), items, fp); 3044 rc = put_entry(buf, sizeof(u32), items, fp);
3045 if (rc) 3045 if (rc)
3046 return rc; 3046 return rc;
@@ -3069,7 +3069,7 @@ static int user_write(void *vkey, void *datum, void *ptr)
3069 buf[items++] = cpu_to_le32(usrdatum->value); 3069 buf[items++] = cpu_to_le32(usrdatum->value);
3070 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY) 3070 if (p->policyvers >= POLICYDB_VERSION_BOUNDARY)
3071 buf[items++] = cpu_to_le32(usrdatum->bounds); 3071 buf[items++] = cpu_to_le32(usrdatum->bounds);
3072 BUG_ON(items > (sizeof(buf) / sizeof(buf[0]))); 3072 BUG_ON(items > ARRAY_SIZE(buf));
3073 rc = put_entry(buf, sizeof(u32), items, fp); 3073 rc = put_entry(buf, sizeof(u32), items, fp);
3074 if (rc) 3074 if (rc)
3075 return rc; 3075 return rc;