Commit 2ced3dfd authored by Eric Paris's avatar Eric Paris Committed by James Morris

changing whitespace for fun and profit: policydb.c

More formatting changes.  Aside from the 80 character line limit even
the checkpatch scripts like this file now.  Too bad I don't get paid by
the lines of code I change.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 828dfe1d
...@@ -51,7 +51,7 @@ static char *symtab_name[SYM_NUM] = { ...@@ -51,7 +51,7 @@ static char *symtab_name[SYM_NUM] = {
}; };
#endif #endif
int selinux_mls_enabled = 0; int selinux_mls_enabled;
static unsigned int symtab_sizes[SYM_NUM] = { static unsigned int symtab_sizes[SYM_NUM] = {
2, 2,
...@@ -152,7 +152,7 @@ static int roles_init(struct policydb *p) ...@@ -152,7 +152,7 @@ static int roles_init(struct policydb *p)
rc = -EINVAL; rc = -EINVAL;
goto out_free_role; goto out_free_role;
} }
key = kmalloc(strlen(OBJECT_R)+1,GFP_KERNEL); key = kmalloc(strlen(OBJECT_R)+1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_free_role; goto out_free_role;
...@@ -634,7 +634,7 @@ void policydb_destroy(struct policydb *p) ...@@ -634,7 +634,7 @@ void policydb_destroy(struct policydb *p)
while (c) { while (c) {
ctmp = c; ctmp = c;
c = c->next; c = c->next;
ocontext_destroy(ctmp,i); ocontext_destroy(ctmp, i);
} }
p->ocontexts[i] = NULL; p->ocontexts[i] = NULL;
} }
...@@ -647,7 +647,7 @@ void policydb_destroy(struct policydb *p) ...@@ -647,7 +647,7 @@ void policydb_destroy(struct policydb *p)
while (c) { while (c) {
ctmp = c; ctmp = c;
c = c->next; c = c->next;
ocontext_destroy(ctmp,OCON_FSUSE); ocontext_destroy(ctmp, OCON_FSUSE);
} }
gtmp = g; gtmp = g;
g = g->next; g = g->next;
...@@ -664,14 +664,14 @@ void policydb_destroy(struct policydb *p) ...@@ -664,14 +664,14 @@ void policydb_destroy(struct policydb *p)
} }
kfree(ltr); kfree(ltr);
for (ra = p->role_allow; ra; ra = ra -> next) { for (ra = p->role_allow; ra; ra = ra->next) {
cond_resched(); cond_resched();
kfree(lra); kfree(lra);
lra = ra; lra = ra;
} }
kfree(lra); kfree(lra);
for (rt = p->range_tr; rt; rt = rt -> next) { for (rt = p->range_tr; rt; rt = rt->next) {
cond_resched(); cond_resched();
if (lrt) { if (lrt) {
ebitmap_destroy(&lrt->target_range.level[0].cat); ebitmap_destroy(&lrt->target_range.level[0].cat);
...@@ -924,7 +924,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -924,7 +924,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp)
len = le32_to_cpu(buf[0]); len = le32_to_cpu(buf[0]);
perdatum->value = le32_to_cpu(buf[1]); perdatum->value = le32_to_cpu(buf[1]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -971,7 +971,7 @@ static int common_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -971,7 +971,7 @@ static int common_read(struct policydb *p, struct hashtab *h, void *fp)
comdatum->permissions.nprim = le32_to_cpu(buf[2]); comdatum->permissions.nprim = le32_to_cpu(buf[2]);
nel = le32_to_cpu(buf[3]); nel = le32_to_cpu(buf[3]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1012,11 +1012,10 @@ static int read_cons_helper(struct constraint_node **nodep, int ncons, ...@@ -1012,11 +1012,10 @@ static int read_cons_helper(struct constraint_node **nodep, int ncons,
if (!c) if (!c)
return -ENOMEM; return -ENOMEM;
if (lc) { if (lc)
lc->next = c; lc->next = c;
} else { else
*nodep = c; *nodep = c;
}
rc = next_entry(buf, fp, (sizeof(u32) * 2)); rc = next_entry(buf, fp, (sizeof(u32) * 2));
if (rc < 0) if (rc < 0)
...@@ -1030,11 +1029,10 @@ static int read_cons_helper(struct constraint_node **nodep, int ncons, ...@@ -1030,11 +1029,10 @@ static int read_cons_helper(struct constraint_node **nodep, int ncons,
if (!e) if (!e)
return -ENOMEM; return -ENOMEM;
if (le) { if (le)
le->next = e; le->next = e;
} else { else
c->expr = e; c->expr = e;
}
rc = next_entry(buf, fp, (sizeof(u32) * 3)); rc = next_entry(buf, fp, (sizeof(u32) * 3));
if (rc < 0) if (rc < 0)
...@@ -1111,7 +1109,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1111,7 +1109,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
ncons = le32_to_cpu(buf[5]); ncons = le32_to_cpu(buf[5]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1122,7 +1120,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1122,7 +1120,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
key[len] = 0; key[len] = 0;
if (len2) { if (len2) {
cladatum->comkey = kmalloc(len2 + 1,GFP_KERNEL); cladatum->comkey = kmalloc(len2 + 1, GFP_KERNEL);
if (!cladatum->comkey) { if (!cladatum->comkey) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1195,7 +1193,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1195,7 +1193,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
len = le32_to_cpu(buf[0]); len = le32_to_cpu(buf[0]);
role->value = le32_to_cpu(buf[1]); role->value = le32_to_cpu(buf[1]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1242,7 +1240,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1242,7 +1240,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
__le32 buf[3]; __le32 buf[3];
u32 len; u32 len;
typdatum = kzalloc(sizeof(*typdatum),GFP_KERNEL); typdatum = kzalloc(sizeof(*typdatum), GFP_KERNEL);
if (!typdatum) { if (!typdatum) {
rc = -ENOMEM; rc = -ENOMEM;
return rc; return rc;
...@@ -1256,7 +1254,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1256,7 +1254,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
typdatum->value = le32_to_cpu(buf[1]); typdatum->value = le32_to_cpu(buf[1]);
typdatum->primary = le32_to_cpu(buf[2]); typdatum->primary = le32_to_cpu(buf[2]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1328,7 +1326,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1328,7 +1326,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
len = le32_to_cpu(buf[0]); len = le32_to_cpu(buf[0]);
usrdatum->value = le32_to_cpu(buf[1]); usrdatum->value = le32_to_cpu(buf[1]);
key = kmalloc(len + 1,GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1382,7 +1380,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1382,7 +1380,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp)
len = le32_to_cpu(buf[0]); len = le32_to_cpu(buf[0]);
levdatum->isalias = le32_to_cpu(buf[1]); levdatum->isalias = le32_to_cpu(buf[1]);
key = kmalloc(len + 1,GFP_ATOMIC); key = kmalloc(len + 1, GFP_ATOMIC);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1434,7 +1432,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1434,7 +1432,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp)
catdatum->value = le32_to_cpu(buf[1]); catdatum->value = le32_to_cpu(buf[1]);
catdatum->isalias = le32_to_cpu(buf[2]); catdatum->isalias = le32_to_cpu(buf[2]);
key = kmalloc(len + 1,GFP_ATOMIC); key = kmalloc(len + 1, GFP_ATOMIC);
if (!key) { if (!key) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1493,7 +1491,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1493,7 +1491,7 @@ int policydb_read(struct policydb *p, void *fp)
goto out; goto out;
/* Read the magic number and string length. */ /* Read the magic number and string length. */
rc = next_entry(buf, fp, sizeof(u32)* 2); rc = next_entry(buf, fp, sizeof(u32) * 2);
if (rc < 0) if (rc < 0)
goto bad; goto bad;
...@@ -1511,7 +1509,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1511,7 +1509,7 @@ int policydb_read(struct policydb *p, void *fp)
len, strlen(POLICYDB_STRING)); len, strlen(POLICYDB_STRING));
goto bad; goto bad;
} }
policydb_str = kmalloc(len + 1,GFP_KERNEL); policydb_str = kmalloc(len + 1, GFP_KERNEL);
if (!policydb_str) { if (!policydb_str) {
printk(KERN_ERR "SELinux: unable to allocate memory for policydb " printk(KERN_ERR "SELinux: unable to allocate memory for policydb "
"string of length %d\n", len); "string of length %d\n", len);
...@@ -1634,11 +1632,10 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1634,11 +1632,10 @@ int policydb_read(struct policydb *p, void *fp)
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
} }
if (ltr) { if (ltr)
ltr->next = tr; ltr->next = tr;
} else { else
p->role_tr = tr; p->role_tr = tr;
}
rc = next_entry(buf, fp, sizeof(u32)*3); rc = next_entry(buf, fp, sizeof(u32)*3);
if (rc < 0) if (rc < 0)
goto bad; goto bad;
...@@ -1665,11 +1662,10 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1665,11 +1662,10 @@ int policydb_read(struct policydb *p, void *fp)
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
} }
if (lra) { if (lra)
lra->next = ra; lra->next = ra;
} else { else
p->role_allow = ra; p->role_allow = ra;
}
rc = next_entry(buf, fp, sizeof(u32)*2); rc = next_entry(buf, fp, sizeof(u32)*2);
if (rc < 0) if (rc < 0)
goto bad; goto bad;
...@@ -1703,11 +1699,10 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1703,11 +1699,10 @@ int policydb_read(struct policydb *p, void *fp)
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
} }
if (l) { if (l)
l->next = c; l->next = c;
} else { else
p->ocontexts[i] = c; p->ocontexts[i] = c;
}
l = c; l = c;
rc = -EINVAL; rc = -EINVAL;
switch (i) { switch (i) {
...@@ -1726,7 +1721,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1726,7 +1721,7 @@ int policydb_read(struct policydb *p, void *fp)
if (rc < 0) if (rc < 0)
goto bad; goto bad;
len = le32_to_cpu(buf[0]); len = le32_to_cpu(buf[0]);
c->u.name = kmalloc(len + 1,GFP_KERNEL); c->u.name = kmalloc(len + 1, GFP_KERNEL);
if (!c->u.name) { if (!c->u.name) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1754,7 +1749,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1754,7 +1749,7 @@ int policydb_read(struct policydb *p, void *fp)
goto bad; goto bad;
break; break;
case OCON_NODE: case OCON_NODE:
rc = next_entry(buf, fp, sizeof(u32)* 2); rc = next_entry(buf, fp, sizeof(u32) * 2);
if (rc < 0) if (rc < 0)
goto bad; goto bad;
c->u.node.addr = le32_to_cpu(buf[0]); c->u.node.addr = le32_to_cpu(buf[0]);
...@@ -1771,7 +1766,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1771,7 +1766,7 @@ int policydb_read(struct policydb *p, void *fp)
if (c->v.behavior > SECURITY_FS_USE_NONE) if (c->v.behavior > SECURITY_FS_USE_NONE)
goto bad; goto bad;
len = le32_to_cpu(buf[1]); len = le32_to_cpu(buf[1]);
c->u.name = kmalloc(len + 1,GFP_KERNEL); c->u.name = kmalloc(len + 1, GFP_KERNEL);
if (!c->u.name) { if (!c->u.name) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad; goto bad;
...@@ -1819,7 +1814,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1819,7 +1814,7 @@ int policydb_read(struct policydb *p, void *fp)
goto bad; goto bad;
} }
newgenfs->fstype = kmalloc(len + 1,GFP_KERNEL); newgenfs->fstype = kmalloc(len + 1, GFP_KERNEL);
if (!newgenfs->fstype) { if (!newgenfs->fstype) {
rc = -ENOMEM; rc = -ENOMEM;
kfree(newgenfs); kfree(newgenfs);
...@@ -1865,7 +1860,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1865,7 +1860,7 @@ int policydb_read(struct policydb *p, void *fp)
goto bad; goto bad;
} }
newc->u.name = kmalloc(len + 1,GFP_KERNEL); newc->u.name = kmalloc(len + 1, GFP_KERNEL);
if (!newc->u.name) { if (!newc->u.name) {
rc = -ENOMEM; rc = -ENOMEM;
goto bad_newc; goto bad_newc;
...@@ -1969,7 +1964,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -1969,7 +1964,7 @@ int policydb_read(struct policydb *p, void *fp)
out: out:
return rc; return rc;
bad_newc: bad_newc:
ocontext_destroy(newc,OCON_FSUSE); ocontext_destroy(newc, OCON_FSUSE);
bad: bad:
if (!rc) if (!rc)
rc = -EINVAL; rc = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment