Skip to content

Commit e951485

Browse files
committed
selinux: fix style issues in security/selinux/ss/ebitmap.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 <[email protected]>
1 parent 3ec3a83 commit e951485

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

security/selinux/ss/ebitmap.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
33
* Implementation of the extensible bitmap type.
44
*
55
* Author : Stephen Smalley, <[email protected]>
66
*/
77
/*
88
* Updated: Hewlett-Packard <[email protected]>
9+
* Added support to import/export the NetLabel category bitmap
10+
* (c) Copyright Hewlett-Packard Development Company, L.P., 2006
911
*
10-
* Added support to import/export the NetLabel category bitmap
11-
*
12-
* (c) Copyright Hewlett-Packard Development Company, L.P., 2006
13-
*/
14-
/*
1512
* Updated: KaiGai Kohei <[email protected]>
16-
* Applied standard bit operations to improve bitmap scanning.
13+
* Applied standard bit operations to improve bitmap scanning.
1714
*/
1815

1916
#include <linux/kernel.h>
@@ -24,7 +21,7 @@
2421
#include "ebitmap.h"
2522
#include "policydb.h"
2623

27-
#define BITS_PER_U64 (sizeof(u64) * 8)
24+
#define BITS_PER_U64 (sizeof(u64) * 8)
2825

2926
static struct kmem_cache *ebitmap_node_cachep __ro_after_init;
3027

@@ -37,8 +34,7 @@ int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2)
3734

3835
n1 = e1->node;
3936
n2 = e2->node;
40-
while (n1 && n2 &&
41-
(n1->startbit == n2->startbit) &&
37+
while (n1 && n2 && (n1->startbit == n2->startbit) &&
4238
!memcmp(n1->maps, n2->maps, EBITMAP_SIZE / 8)) {
4339
n1 = n1->next;
4440
n2 = n2->next;
@@ -79,14 +75,16 @@ int ebitmap_cpy(struct ebitmap *dst, const struct ebitmap *src)
7975
return 0;
8076
}
8177

82-
int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, const struct ebitmap *e2)
78+
int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1,
79+
const struct ebitmap *e2)
8380
{
8481
struct ebitmap_node *n;
8582
int bit, rc;
8683

8784
ebitmap_init(dst);
8885

89-
ebitmap_for_each_positive_bit(e1, n, bit) {
86+
ebitmap_for_each_positive_bit(e1, n, bit)
87+
{
9088
if (ebitmap_get_bit(e2, bit)) {
9189
rc = ebitmap_set_bit(dst, bit, 1);
9290
if (rc < 0)
@@ -96,7 +94,6 @@ int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1, const struct ebit
9694
return 0;
9795
}
9896

99-
10097
#ifdef CONFIG_NETLABEL
10198
/**
10299
* ebitmap_netlbl_export - Export an ebitmap into a NetLabel category bitmap
@@ -131,10 +128,8 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap,
131128
for (iter = 0; iter < EBITMAP_UNIT_NUMS; iter++) {
132129
e_map = e_iter->maps[iter];
133130
if (e_map != 0) {
134-
rc = netlbl_catmap_setlong(catmap,
135-
offset,
136-
e_map,
137-
GFP_ATOMIC);
131+
rc = netlbl_catmap_setlong(catmap, offset,
132+
e_map, GFP_ATOMIC);
138133
if (rc != 0)
139134
goto netlbl_export_failure;
140135
}
@@ -185,7 +180,8 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
185180
if (e_iter == NULL ||
186181
offset >= e_iter->startbit + EBITMAP_SIZE) {
187182
e_prev = e_iter;
188-
e_iter = kmem_cache_zalloc(ebitmap_node_cachep, GFP_ATOMIC);
183+
e_iter = kmem_cache_zalloc(ebitmap_node_cachep,
184+
GFP_ATOMIC);
189185
if (e_iter == NULL)
190186
goto netlbl_import_failure;
191187
e_iter->startbit = offset - (offset % EBITMAP_SIZE);
@@ -218,7 +214,8 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
218214
* if last_e2bit is non-zero, the highest set bit in e2 cannot exceed
219215
* last_e2bit.
220216
*/
221-
int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, u32 last_e2bit)
217+
int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2,
218+
u32 last_e2bit)
222219
{
223220
const struct ebitmap_node *n1, *n2;
224221
int i;
@@ -234,8 +231,8 @@ int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2, u32 las
234231
n1 = n1->next;
235232
continue;
236233
}
237-
for (i = EBITMAP_UNIT_NUMS - 1; (i >= 0) && !n2->maps[i]; )
238-
i--; /* Skip trailing NULL map entries */
234+
for (i = EBITMAP_UNIT_NUMS - 1; (i >= 0) && !n2->maps[i];)
235+
i--; /* Skip trailing NULL map entries */
239236
if (last_e2bit && (i >= 0)) {
240237
u32 lastsetbit = n2->startbit + i * EBITMAP_UNIT_SIZE +
241238
__fls(n2->maps[i]);
@@ -302,8 +299,8 @@ int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value)
302299
* within the bitmap
303300
*/
304301
if (prev)
305-
e->highbit = prev->startbit
306-
+ EBITMAP_SIZE;
302+
e->highbit = prev->startbit +
303+
EBITMAP_SIZE;
307304
else
308305
e->highbit = 0;
309306
}
@@ -424,7 +421,8 @@ int ebitmap_read(struct ebitmap *e, void *fp)
424421

425422
if (!n || startbit >= n->startbit + EBITMAP_SIZE) {
426423
struct ebitmap_node *tmp;
427-
tmp = kmem_cache_zalloc(ebitmap_node_cachep, GFP_KERNEL);
424+
tmp = kmem_cache_zalloc(ebitmap_node_cachep,
425+
GFP_KERNEL);
428426
if (!tmp) {
429427
pr_err("SELinux: ebitmap: out of memory\n");
430428
rc = -ENOMEM;
@@ -481,7 +479,8 @@ int ebitmap_write(const struct ebitmap *e, void *fp)
481479
count = 0;
482480
last_bit = 0;
483481
last_startbit = -1;
484-
ebitmap_for_each_positive_bit(e, n, bit) {
482+
ebitmap_for_each_positive_bit(e, n, bit)
483+
{
485484
if (rounddown(bit, (int)BITS_PER_U64) > last_startbit) {
486485
count++;
487486
last_startbit = rounddown(bit, BITS_PER_U64);
@@ -497,7 +496,8 @@ int ebitmap_write(const struct ebitmap *e, void *fp)
497496

498497
map = 0;
499498
last_startbit = INT_MIN;
500-
ebitmap_for_each_positive_bit(e, n, bit) {
499+
ebitmap_for_each_positive_bit(e, n, bit)
500+
{
501501
if (rounddown(bit, (int)BITS_PER_U64) > last_startbit) {
502502
__le64 buf64[1];
503503

@@ -559,6 +559,6 @@ u32 ebitmap_hash(const struct ebitmap *e, u32 hash)
559559
void __init ebitmap_cache_init(void)
560560
{
561561
ebitmap_node_cachep = kmem_cache_create("ebitmap_node",
562-
sizeof(struct ebitmap_node),
563-
0, SLAB_PANIC, NULL);
562+
sizeof(struct ebitmap_node), 0,
563+
SLAB_PANIC, NULL);
564564
}

0 commit comments

Comments
 (0)