diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2020-04-28 14:55:11 +0200 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2020-05-01 16:08:04 -0400 |
commit | 3348bd33e8cf8a17138e8ce716ae474ec5d7001e (patch) | |
tree | 3e6c4684a1f89b5b61bc6c8e510b39021f3ccfff /security/selinux | |
parent | 4c09f8b6913a779ca0c70ea8058bf21537eebb3b (diff) | |
download | linux-3348bd33e8cf8a17138e8ce716ae474ec5d7001e.tar.gz |
selinux: simplify range_write()
No need to traverse the hashtab to count its elements, hashtab already
tracks it for us.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r-- | security/selinux/ss/policydb.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index a42369dd96a9..8a287a7afd9f 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -3405,14 +3405,6 @@ static int genfs_write(struct policydb *p, void *fp) return 0; } -static int hashtab_cnt(void *key, void *data, void *ptr) -{ - int *cnt = ptr; - *cnt = *cnt + 1; - - return 0; -} - static int range_write_helper(void *key, void *data, void *ptr) { __le32 buf[2]; @@ -3444,19 +3436,13 @@ static int range_write_helper(void *key, void *data, void *ptr) static int range_write(struct policydb *p, void *fp) { __le32 buf[1]; - int rc, nel; + int rc; struct policy_data pd; pd.p = p; pd.fp = fp; - /* count the number of entries in the hashtab */ - nel = 0; - rc = hashtab_map(p->range_tr, hashtab_cnt, &nel); - if (rc) - return rc; - - buf[0] = cpu_to_le32(nel); + buf[0] = cpu_to_le32(p->range_tr->nel); rc = put_entry(buf, sizeof(u32), 1, fp); if (rc) return rc; |