* [PATCH] selinux: avtab_init() and cond_policydb_init() return void
@ 2020-03-05 20:04 Paul Moore
2020-03-06 10:12 ` Ondrej Mosnacek
0 siblings, 1 reply; 4+ messages in thread
From: Paul Moore @ 2020-03-05 20:04 UTC (permalink / raw)
To: selinux
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: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
---
security/selinux/ss/avtab.c | 3 +--
security/selinux/ss/avtab.h | 2 +-
security/selinux/ss/conditional.c | 10 ++--------
security/selinux/ss/conditional.h | 2 +-
security/selinux/ss/policydb.c | 11 ++---------
5 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
index 8c5800750fa8..01b300a4a882 100644
--- a/security/selinux/ss/avtab.c
+++ b/security/selinux/ss/avtab.c
@@ -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)
diff --git a/security/selinux/ss/avtab.h b/security/selinux/ss/avtab.h
index 837e938798ef..5fdcb6696bcc 100644
--- a/security/selinux/ss/avtab.h
+++ b/security/selinux/ss/avtab.h
@@ -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);
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index cce4a75fb3e7..939a74fd8fb4 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -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)
diff --git a/security/selinux/ss/conditional.h b/security/selinux/ss/conditional.h
index b9eb888ffa76..90c9c964f5f5 100644
--- a/security/selinux/ss/conditional.h
+++ b/security/selinux/ss/conditional.h
@@ -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);
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 00edcd216aaa..932b2b9bcdb2 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -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));
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: avtab_init() and cond_policydb_init() return void
2020-03-05 20:04 [PATCH] selinux: avtab_init() and cond_policydb_init() return void Paul Moore
@ 2020-03-06 10:12 ` Ondrej Mosnacek
2020-03-06 13:39 ` Paul Moore
0 siblings, 1 reply; 4+ messages in thread
From: Ondrej Mosnacek @ 2020-03-06 10:12 UTC (permalink / raw)
To: Paul Moore; +Cc: SElinux list
On Thu, Mar 5, 2020 at 9:04 PM Paul Moore <paul@paul-moore.com> wrote:
> 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: Ondrej Mosnacek <omosnace@redhat.com>
This was originally suggested by Stephen - you should credit him, not
me :) I only expressed my preference to still keep the functions,
since Stephen was considering removing them completely.
Other than that,
Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
> security/selinux/ss/avtab.c | 3 +--
> security/selinux/ss/avtab.h | 2 +-
> security/selinux/ss/conditional.c | 10 ++--------
> security/selinux/ss/conditional.h | 2 +-
> security/selinux/ss/policydb.c | 11 ++---------
> 5 files changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
> index 8c5800750fa8..01b300a4a882 100644
> --- a/security/selinux/ss/avtab.c
> +++ b/security/selinux/ss/avtab.c
> @@ -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)
> diff --git a/security/selinux/ss/avtab.h b/security/selinux/ss/avtab.h
> index 837e938798ef..5fdcb6696bcc 100644
> --- a/security/selinux/ss/avtab.h
> +++ b/security/selinux/ss/avtab.h
> @@ -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);
> diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> index cce4a75fb3e7..939a74fd8fb4 100644
> --- a/security/selinux/ss/conditional.c
> +++ b/security/selinux/ss/conditional.c
> @@ -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)
> diff --git a/security/selinux/ss/conditional.h b/security/selinux/ss/conditional.h
> index b9eb888ffa76..90c9c964f5f5 100644
> --- a/security/selinux/ss/conditional.h
> +++ b/security/selinux/ss/conditional.h
> @@ -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);
> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
> index 00edcd216aaa..932b2b9bcdb2 100644
> --- a/security/selinux/ss/policydb.c
> +++ b/security/selinux/ss/policydb.c
> @@ -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));
>
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: avtab_init() and cond_policydb_init() return void
2020-03-06 10:12 ` Ondrej Mosnacek
@ 2020-03-06 13:39 ` Paul Moore
2020-03-06 17:24 ` Paul Moore
0 siblings, 1 reply; 4+ messages in thread
From: Paul Moore @ 2020-03-06 13:39 UTC (permalink / raw)
To: Ondrej Mosnacek, Stephen Smalley; +Cc: SElinux list
On Fri, Mar 6, 2020 at 5:12 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> On Thu, Mar 5, 2020 at 9:04 PM Paul Moore <paul@paul-moore.com> wrote:
> > 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: Ondrej Mosnacek <omosnace@redhat.com>
>
> This was originally suggested by Stephen - you should credit him, not
> me :) I only expressed my preference to still keep the functions,
> since Stephen was considering removing them completely.
Ooops, sorry Stephen!
Fixed in my local copy, and assuming I don't hear any objections in
the next few hours I'll go ahead and merge it. It's a pretty trivial
patch anyway.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selinux: avtab_init() and cond_policydb_init() return void
2020-03-06 13:39 ` Paul Moore
@ 2020-03-06 17:24 ` Paul Moore
0 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2020-03-06 17:24 UTC (permalink / raw)
To: Ondrej Mosnacek, Stephen Smalley; +Cc: SElinux list
On Fri, Mar 6, 2020 at 8:39 AM Paul Moore <paul@paul-moore.com> wrote:
> On Fri, Mar 6, 2020 at 5:12 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > On Thu, Mar 5, 2020 at 9:04 PM Paul Moore <paul@paul-moore.com> wrote:
> > > 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: Ondrej Mosnacek <omosnace@redhat.com>
> >
> > This was originally suggested by Stephen - you should credit him, not
> > me :) I only expressed my preference to still keep the functions,
> > since Stephen was considering removing them completely.
>
> Ooops, sorry Stephen!
>
> Fixed in my local copy, and assuming I don't hear any objections in
> the next few hours I'll go ahead and merge it. It's a pretty trivial
> patch anyway.
Time is up. I just merged the patch into selinux/next.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-06 17:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05 20:04 [PATCH] selinux: avtab_init() and cond_policydb_init() return void Paul Moore
2020-03-06 10:12 ` Ondrej Mosnacek
2020-03-06 13:39 ` Paul Moore
2020-03-06 17:24 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).