Skip to content

Commit ade6a96

Browse files
committed
selinux: fix style issues in security/selinux/ss/conditional.c
As part of on ongoing effort to perform more automated testing and provide more tools for individual developers to validate their patches before submitting, we are trying to make our code "clang-format clean". My hope is that once we have fixed all of our style "quirks", developers will be able to run clang-format on their patches to help avoid silly formatting problems and ensure their changes fit in well with the rest of the SELinux kernel code. Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 1602a6c commit ade6a96

File tree

1 file changed

+33
-35
lines changed

1 file changed

+33
-35
lines changed

security/selinux/ss/conditional.c

+33-35
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// SPDX-License-Identifier: GPL-2.0-only
1+
/* SPDX-License-Identifier: GPL-2.0-only */
22
/* Authors: Karl MacMillan <kmacmillan@tresys.com>
33
* Frank Mayer <mayerf@tresys.com>
4-
*
5-
* Copyright (C) 2003 - 2004 Tresys Technology, LLC
4+
* Copyright (C) 2003 - 2004 Tresys Technology, LLC
65
*/
76

87
#include <linux/kernel.h>
@@ -166,9 +165,8 @@ void cond_policydb_destroy(struct policydb *p)
166165
int cond_init_bool_indexes(struct policydb *p)
167166
{
168167
kfree(p->bool_val_to_struct);
169-
p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim,
170-
sizeof(*p->bool_val_to_struct),
171-
GFP_KERNEL);
168+
p->bool_val_to_struct = kmalloc_array(
169+
p->p_bools.nprim, sizeof(*p->bool_val_to_struct), GFP_KERNEL);
172170
if (!p->bool_val_to_struct)
173171
return -ENOMEM;
174172
return 0;
@@ -287,7 +285,8 @@ static int cond_insertf(struct avtab *a, const struct avtab_key *k,
287285
if (other) {
288286
node_ptr = avtab_search_node(&p->te_cond_avtab, k);
289287
if (node_ptr) {
290-
if (avtab_search_node_next(node_ptr, k->specified)) {
288+
if (avtab_search_node_next(node_ptr,
289+
k->specified)) {
291290
pr_err("SELinux: too many conflicting type rules.\n");
292291
return -EINVAL;
293292
}
@@ -478,8 +477,8 @@ int cond_write_bool(void *vkey, void *datum, void *ptr)
478477
* the conditional. This means that the avtab with the conditional
479478
* rules will not be saved but will be rebuilt on policy load.
480479
*/
481-
static int cond_write_av_list(struct policydb *p,
482-
struct cond_av_list *list, struct policy_file *fp)
480+
static int cond_write_av_list(struct policydb *p, struct cond_av_list *list,
481+
struct policy_file *fp)
483482
{
484483
__le32 buf[1];
485484
u32 i;
@@ -500,7 +499,7 @@ static int cond_write_av_list(struct policydb *p,
500499
}
501500

502501
static int cond_write_node(struct policydb *p, struct cond_node *node,
503-
struct policy_file *fp)
502+
struct policy_file *fp)
504503
{
505504
__le32 buf[2];
506505
int rc;
@@ -555,15 +554,15 @@ int cond_write_list(struct policydb *p, void *fp)
555554
}
556555

557556
void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
558-
struct extended_perms_decision *xpermd)
557+
struct extended_perms_decision *xpermd)
559558
{
560559
struct avtab_node *node;
561560

562561
if (!ctab || !key || !xpermd)
563562
return;
564563

565564
for (node = avtab_search_node(ctab, key); node;
566-
node = avtab_search_node_next(node, key->specified)) {
565+
node = avtab_search_node_next(node, key->specified)) {
567566
if (node->key.specified & AVTAB_ENABLED)
568567
services_compute_xperms_decision(xpermd, node);
569568
}
@@ -572,38 +571,37 @@ void cond_compute_xperms(struct avtab *ctab, struct avtab_key *key,
572571
* av table, and if so, add them to the result
573572
*/
574573
void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
575-
struct av_decision *avd, struct extended_perms *xperms)
574+
struct av_decision *avd, struct extended_perms *xperms)
576575
{
577576
struct avtab_node *node;
578577

579578
if (!ctab || !key || !avd)
580579
return;
581580

582581
for (node = avtab_search_node(ctab, key); node;
583-
node = avtab_search_node_next(node, key->specified)) {
584-
if ((u16)(AVTAB_ALLOWED|AVTAB_ENABLED) ==
585-
(node->key.specified & (AVTAB_ALLOWED|AVTAB_ENABLED)))
582+
node = avtab_search_node_next(node, key->specified)) {
583+
if ((u16)(AVTAB_ALLOWED | AVTAB_ENABLED) ==
584+
(node->key.specified & (AVTAB_ALLOWED | AVTAB_ENABLED)))
586585
avd->allowed |= node->datum.u.data;
587-
if ((u16)(AVTAB_AUDITDENY|AVTAB_ENABLED) ==
588-
(node->key.specified & (AVTAB_AUDITDENY|AVTAB_ENABLED)))
586+
if ((u16)(AVTAB_AUDITDENY | AVTAB_ENABLED) ==
587+
(node->key.specified & (AVTAB_AUDITDENY | AVTAB_ENABLED)))
589588
/* Since a '0' in an auditdeny mask represents a
590589
* permission we do NOT want to audit (dontaudit), we use
591590
* the '&' operand to ensure that all '0's in the mask
592591
* are retained (much unlike the allow and auditallow cases).
593592
*/
594593
avd->auditdeny &= node->datum.u.data;
595-
if ((u16)(AVTAB_AUDITALLOW|AVTAB_ENABLED) ==
596-
(node->key.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED)))
594+
if ((u16)(AVTAB_AUDITALLOW | AVTAB_ENABLED) ==
595+
(node->key.specified & (AVTAB_AUDITALLOW | AVTAB_ENABLED)))
597596
avd->auditallow |= node->datum.u.data;
598597
if (xperms && (node->key.specified & AVTAB_ENABLED) &&
599-
(node->key.specified & AVTAB_XPERMS))
598+
(node->key.specified & AVTAB_XPERMS))
600599
services_compute_xperms_drivers(xperms, node);
601600
}
602601
}
603602

604-
static int cond_dup_av_list(struct cond_av_list *new,
605-
struct cond_av_list *orig,
606-
struct avtab *avtab)
603+
static int cond_dup_av_list(struct cond_av_list *new, struct cond_av_list *orig,
604+
struct avtab *avtab)
607605
{
608606
u32 i;
609607

@@ -614,9 +612,8 @@ static int cond_dup_av_list(struct cond_av_list *new,
614612
return -ENOMEM;
615613

616614
for (i = 0; i < orig->len; i++) {
617-
new->nodes[i] = avtab_insert_nonunique(avtab,
618-
&orig->nodes[i]->key,
619-
&orig->nodes[i]->datum);
615+
new->nodes[i] = avtab_insert_nonunique(
616+
avtab, &orig->nodes[i]->key, &orig->nodes[i]->datum);
620617
if (!new->nodes[i])
621618
return -ENOMEM;
622619
new->len++;
@@ -637,8 +634,7 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
637634

638635
newp->cond_list_len = 0;
639636
newp->cond_list = kcalloc(origp->cond_list_len,
640-
sizeof(*newp->cond_list),
641-
GFP_KERNEL);
637+
sizeof(*newp->cond_list), GFP_KERNEL);
642638
if (!newp->cond_list)
643639
goto error;
644640

@@ -649,7 +645,8 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
649645
newp->cond_list_len++;
650646

651647
newn->cur_state = orign->cur_state;
652-
newn->expr.nodes = kmemdup(orign->expr.nodes,
648+
newn->expr.nodes =
649+
kmemdup(orign->expr.nodes,
653650
orign->expr.len * sizeof(*orign->expr.nodes),
654651
GFP_KERNEL);
655652
if (!newn->expr.nodes)
@@ -658,12 +655,12 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
658655
newn->expr.len = orign->expr.len;
659656

660657
rc = cond_dup_av_list(&newn->true_list, &orign->true_list,
661-
&newp->te_cond_avtab);
658+
&newp->te_cond_avtab);
662659
if (rc)
663660
goto error;
664661

665662
rc = cond_dup_av_list(&newn->false_list, &orign->false_list,
666-
&newp->te_cond_avtab);
663+
&newp->te_cond_avtab);
667664
if (rc)
668665
goto error;
669666
}
@@ -683,7 +680,8 @@ static int cond_bools_destroy(void *key, void *datum, void *args)
683680
return 0;
684681
}
685682

686-
static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig, void *args)
683+
static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig,
684+
void *args)
687685
{
688686
struct cond_bool_datum *datum;
689687

@@ -709,7 +707,7 @@ static int cond_bools_index(void *key, void *datum, void *args)
709707
}
710708

711709
static int duplicate_policydb_bools(struct policydb *newdb,
712-
struct policydb *orig)
710+
struct policydb *orig)
713711
{
714712
struct cond_bool_datum **cond_bool_array;
715713
int rc;
@@ -721,7 +719,7 @@ static int duplicate_policydb_bools(struct policydb *newdb,
721719
return -ENOMEM;
722720

723721
rc = hashtab_duplicate(&newdb->p_bools.table, &orig->p_bools.table,
724-
cond_bools_copy, cond_bools_destroy, NULL);
722+
cond_bools_copy, cond_bools_destroy, NULL);
725723
if (rc) {
726724
kfree(cond_bool_array);
727725
return -ENOMEM;

0 commit comments

Comments
 (0)