Skip to content

Commit f075861

Browse files
cgzonespcmoore
authored andcommitted
selinux: use known type instead of void pointer
Improve type safety and readability by using the known type. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 83e7e18 commit f075861

File tree

8 files changed

+77
-74
lines changed

8 files changed

+77
-74
lines changed

security/selinux/ss/avtab.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static const uint16_t spec_order[] = {
336336
};
337337
/* clang-format on */
338338

339-
int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
339+
int avtab_read_item(struct avtab *a, struct policy_file *fp, struct policydb *pol,
340340
int (*insertf)(struct avtab *a, const struct avtab_key *k,
341341
const struct avtab_datum *d, void *p),
342342
void *p, bool conditional)
@@ -507,7 +507,7 @@ static int avtab_insertf(struct avtab *a, const struct avtab_key *k,
507507
return avtab_insert(a, k, d);
508508
}
509509

510-
int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
510+
int avtab_read(struct avtab *a, struct policy_file *fp, struct policydb *pol)
511511
{
512512
int rc;
513513
__le32 buf[1];
@@ -550,7 +550,7 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
550550
goto out;
551551
}
552552

553-
int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp)
553+
int avtab_write_item(struct policydb *p, const struct avtab_node *cur, struct policy_file *fp)
554554
{
555555
__le16 buf16[4];
556556
__le32 buf32[ARRAY_SIZE(cur->datum.u.xperms->perms.p)];
@@ -586,7 +586,7 @@ int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp)
586586
return 0;
587587
}
588588

589-
int avtab_write(struct policydb *p, struct avtab *a, void *fp)
589+
int avtab_write(struct policydb *p, struct avtab *a, struct policy_file *fp)
590590
{
591591
u32 i;
592592
int rc = 0;

security/selinux/ss/avtab.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,16 @@ static inline void avtab_hash_eval(struct avtab *h, const char *tag)
105105
#endif
106106

107107
struct policydb;
108-
int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
108+
struct policy_file;
109+
int avtab_read_item(struct avtab *a, struct policy_file *fp, struct policydb *pol,
109110
int (*insert)(struct avtab *a, const struct avtab_key *k,
110111
const struct avtab_datum *d, void *p),
111112
void *p, bool conditional);
112113

113-
int avtab_read(struct avtab *a, void *fp, struct policydb *pol);
114+
int avtab_read(struct avtab *a, struct policy_file *fp, struct policydb *pol);
114115
int avtab_write_item(struct policydb *p, const struct avtab_node *cur,
115-
void *fp);
116-
int avtab_write(struct policydb *p, struct avtab *a, void *fp);
116+
struct policy_file *fp);
117+
int avtab_write(struct policydb *p, struct avtab *a, struct policy_file *fp);
117118

118119
struct avtab_node *avtab_insert_nonunique(struct avtab *h,
119120
const struct avtab_key *key,

security/selinux/ss/conditional.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int bool_isvalid(struct cond_bool_datum *b)
206206
return 1;
207207
}
208208

209-
int cond_read_bool(struct policydb *p, struct symtab *s, void *fp)
209+
int cond_read_bool(struct policydb *p, struct symtab *s, struct policy_file *fp)
210210
{
211211
char *key = NULL;
212212
struct cond_bool_datum *booldatum;
@@ -323,7 +323,7 @@ static int cond_insertf(struct avtab *a, const struct avtab_key *k,
323323
return 0;
324324
}
325325

326-
static int cond_read_av_list(struct policydb *p, void *fp,
326+
static int cond_read_av_list(struct policydb *p, struct policy_file *fp,
327327
struct cond_av_list *list,
328328
struct cond_av_list *other)
329329
{
@@ -375,7 +375,7 @@ static int expr_node_isvalid(struct policydb *p, struct cond_expr_node *expr)
375375
return 1;
376376
}
377377

378-
static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
378+
static int cond_read_node(struct policydb *p, struct cond_node *node, struct policy_file *fp)
379379
{
380380
__le32 buf[2];
381381
u32 i, len;
@@ -415,7 +415,7 @@ static int cond_read_node(struct policydb *p, struct cond_node *node, void *fp)
415415
return cond_read_av_list(p, fp, &node->false_list, &node->true_list);
416416
}
417417

418-
int cond_read_list(struct policydb *p, void *fp)
418+
int cond_read_list(struct policydb *p, struct policy_file *fp)
419419
{
420420
__le32 buf[1];
421421
u32 i, len;
@@ -453,7 +453,7 @@ int cond_write_bool(void *vkey, void *datum, void *ptr)
453453
char *key = vkey;
454454
struct cond_bool_datum *booldatum = datum;
455455
struct policy_data *pd = ptr;
456-
void *fp = pd->fp;
456+
struct policy_file *fp = pd->fp;
457457
__le32 buf[3];
458458
u32 len;
459459
int rc;
@@ -536,7 +536,7 @@ static int cond_write_node(struct policydb *p, struct cond_node *node,
536536
return 0;
537537
}
538538

539-
int cond_write_list(struct policydb *p, void *fp)
539+
int cond_write_list(struct policydb *p, struct policy_file *fp)
540540
{
541541
u32 i;
542542
__le32 buf[1];

security/selinux/ss/conditional.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ int cond_destroy_bool(void *key, void *datum, void *p);
6868

6969
int cond_index_bool(void *key, void *datum, void *datap);
7070

71-
int cond_read_bool(struct policydb *p, struct symtab *s, void *fp);
72-
int cond_read_list(struct policydb *p, void *fp);
71+
int cond_read_bool(struct policydb *p, struct symtab *s, struct policy_file *fp);
72+
int cond_read_list(struct policydb *p, struct policy_file *fp);
7373
int cond_write_bool(void *key, void *datum, void *ptr);
74-
int cond_write_list(struct policydb *p, void *fp);
74+
int cond_write_list(struct policydb *p, struct policy_file *fp);
7575

7676
void cond_compute_av(struct avtab *ctab, struct avtab_key *key,
7777
struct av_decision *avd, struct extended_perms *xperms);

security/selinux/ss/ebitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void ebitmap_destroy(struct ebitmap *e)
360360
e->node = NULL;
361361
}
362362

363-
int ebitmap_read(struct ebitmap *e, void *fp)
363+
int ebitmap_read(struct ebitmap *e, struct policy_file *fp)
364364
{
365365
struct ebitmap_node *n = NULL;
366366
u32 mapunit, count, startbit, index, i;
@@ -478,7 +478,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
478478
goto out;
479479
}
480480

481-
int ebitmap_write(const struct ebitmap *e, void *fp)
481+
int ebitmap_write(const struct ebitmap *e, struct policy_file *fp)
482482
{
483483
struct ebitmap_node *n;
484484
u32 bit, count, last_bit, last_startbit;

security/selinux/ss/ebitmap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ int ebitmap_contains(const struct ebitmap *e1, const struct ebitmap *e2,
129129
int ebitmap_get_bit(const struct ebitmap *e, u32 bit);
130130
int ebitmap_set_bit(struct ebitmap *e, u32 bit, int value);
131131
void ebitmap_destroy(struct ebitmap *e);
132-
int ebitmap_read(struct ebitmap *e, void *fp);
133-
int ebitmap_write(const struct ebitmap *e, void *fp);
132+
struct policy_file;
133+
int ebitmap_read(struct ebitmap *e, struct policy_file *fp);
134+
int ebitmap_write(const struct ebitmap *e, struct policy_file *fp);
134135
u32 ebitmap_hash(const struct ebitmap *e, u32 hash);
135136

136137
#ifdef CONFIG_NETLABEL

0 commit comments

Comments
 (0)