[1/3] libsepol: skip unnecessary check in build_type_map()
diff mbox series

Message ID 20200227160257.340737-2-omosnace@redhat.com
State Accepted
Headers show
Series
  • libsepol: Speed up policy optimization
Related show

Commit Message

Ondrej Mosnacek Feb. 27, 2020, 4:02 p.m. UTC
I copy-pasted it from a different part of the code, which had to deal
with policydb that isn't final yet. Since we only deal with the final
kernel policy here, we can skip the check for the type datum being NULL.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 libsepol/src/optimize.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Stephen Smalley March 17, 2020, 6:19 p.m. UTC | #1
On Thu, Feb 27, 2020 at 11:03 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> I copy-pasted it from a different part of the code, which had to deal
> with policydb that isn't final yet. Since we only deal with the final
> kernel policy here, we can skip the check for the type datum being NULL.
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
James Carter March 19, 2020, 7:39 p.m. UTC | #2
On Tue, Mar 17, 2020 at 2:20 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
>
> On Thu, Feb 27, 2020 at 11:03 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > I copy-pasted it from a different part of the code, which had to deal
> > with policydb that isn't final yet. Since we only deal with the final
> > kernel policy here, we can skip the check for the type datum being NULL.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

Applied.
Thanks,
Jim

Patch
diff mbox series

diff --git a/libsepol/src/optimize.c b/libsepol/src/optimize.c
index 1e5e97e8..4d835d47 100644
--- a/libsepol/src/optimize.c
+++ b/libsepol/src/optimize.c
@@ -40,8 +40,7 @@  static ebitmap_t *build_type_map(const policydb_t *p)
 		return NULL;
 
 	for (i = 0; i < p->p_types.nprim; i++) {
-		if (p->type_val_to_struct[i] &&
-		    p->type_val_to_struct[i]->flavor != TYPE_ATTRIB) {
+		if (p->type_val_to_struct[i]->flavor != TYPE_ATTRIB) {
 			if (ebitmap_cpy(&map[i], &p->type_attr_map[i]))
 				goto err;
 		} else {