Skip to content

Commit

Permalink
selinux: avtab_init() and cond_policydb_init() return void
Browse files Browse the repository at this point in the history
The avtab_init() and cond_policydb_init() functions always return
zero so mark them as returning void and update the callers not to
check for a return value.

Suggested-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
pcmoore committed Mar 5, 2020
1 parent 34a2dab commit 5e729e1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
3 changes: 1 addition & 2 deletions security/selinux/ss/avtab.c
Expand Up @@ -299,12 +299,11 @@ void avtab_destroy(struct avtab *h)
h->mask = 0;
}

int avtab_init(struct avtab *h)
void avtab_init(struct avtab *h)
{
kvfree(h->htable);
h->htable = NULL;
h->nel = 0;
return 0;
}

int avtab_alloc(struct avtab *h, u32 nrules)
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/ss/avtab.h
Expand Up @@ -87,7 +87,7 @@ struct avtab {
u32 mask; /* mask to compute hash func */
};

int avtab_init(struct avtab *);
void avtab_init(struct avtab *h);
int avtab_alloc(struct avtab *, u32);
struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
void avtab_destroy(struct avtab *h);
Expand Down
10 changes: 2 additions & 8 deletions security/selinux/ss/conditional.c
Expand Up @@ -125,19 +125,13 @@ void evaluate_cond_nodes(struct policydb *p)
evaluate_cond_node(p, &p->cond_list[i]);
}

int cond_policydb_init(struct policydb *p)
void cond_policydb_init(struct policydb *p)
{
int rc;

p->bool_val_to_struct = NULL;
p->cond_list = NULL;
p->cond_list_len = 0;

rc = avtab_init(&p->te_cond_avtab);
if (rc)
return rc;

return 0;
avtab_init(&p->te_cond_avtab);
}

static void cond_node_destroy(struct cond_node *node)
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/ss/conditional.h
Expand Up @@ -61,7 +61,7 @@ struct cond_node {
struct cond_av_list false_list;
};

int cond_policydb_init(struct policydb *p);
void cond_policydb_init(struct policydb *p);
void cond_policydb_destroy(struct policydb *p);

int cond_init_bool_indexes(struct policydb *p);
Expand Down
11 changes: 2 additions & 9 deletions security/selinux/ss/policydb.c
Expand Up @@ -463,17 +463,10 @@ static int rangetr_cmp(struct hashtab *h, const void *k1, const void *k2)
*/
static int policydb_init(struct policydb *p)
{
int rc;

memset(p, 0, sizeof(*p));

rc = avtab_init(&p->te_avtab);
if (rc)
return rc;

rc = cond_policydb_init(p);
if (rc)
return rc;
avtab_init(&p->te_avtab);
cond_policydb_init(p);

p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp,
(1 << 11));
Expand Down

0 comments on commit 5e729e1

Please sign in to comment.