diff options
author | Eric Paris <eparis@redhat.com> | 2011-04-28 15:11:21 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2011-04-28 15:15:52 -0400 |
commit | be30b16d43f4781406de0c08c96501dae4cc5a77 (patch) | |
tree | 957792a2eae5f16a87b79f4ca8aa434b6fa9c7de /security | |
parent | 03a4c0182a156547edd5f2717c1702590fe36bbf (diff) |
SELinux: calculate and print hashtab stats with a generic function
We have custom debug functions like rangetr_hash_eval and symtab_hash_eval
which do the same thing. Just create a generic function that takes the name
of the hash table as an argument instead of having custom functions.
Signed-off-by: Eric Paris <eparis@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r-- | security/selinux/ss/policydb.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 4c1811972b8b..70c863bf715e 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c | |||
@@ -423,32 +423,26 @@ static int (*index_f[SYM_NUM]) (void *key, void *datum, void *datap) = | |||
423 | }; | 423 | }; |
424 | 424 | ||
425 | #ifdef DEBUG_HASHES | 425 | #ifdef DEBUG_HASHES |
426 | static void symtab_hash_eval(struct symtab *s) | 426 | static void hash_eval(struct hashtab *h, const char *hash_name) |
427 | { | 427 | { |
428 | int i; | 428 | struct hashtab_info info; |
429 | |||
430 | for (i = 0; i < SYM_NUM; i++) { | ||
431 | struct hashtab *h = s[i].table; | ||
432 | struct hashtab_info info; | ||
433 | 429 | ||
434 | hashtab_stat(h, &info); | 430 | hashtab_stat(h, &info); |
435 | printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " | 431 | printk(KERN_DEBUG "SELinux: %s: %d entries and %d/%d buckets used, " |
436 | "longest chain length %d\n", symtab_name[i], h->nel, | 432 | "longest chain length %d\n", hash_name, h->nel, |
437 | info.slots_used, h->size, info.max_chain_len); | 433 | info.slots_used, h->size, info.max_chain_len); |
438 | } | ||
439 | } | 434 | } |
440 | 435 | ||
441 | static void rangetr_hash_eval(struct hashtab *h) | 436 | static void symtab_hash_eval(struct symtab *s) |
442 | { | 437 | { |
443 | struct hashtab_info info; | 438 | int i; |
444 | 439 | ||
445 | hashtab_stat(h, &info); | 440 | for (i = 0; i < SYM_NUM; i++) |
446 | printk(KERN_DEBUG "SELinux: rangetr: %d entries and %d/%d buckets used, " | 441 | hash_eval(s[i].table, symtab_name[i]); |
447 | "longest chain length %d\n", h->nel, | ||
448 | info.slots_used, h->size, info.max_chain_len); | ||
449 | } | 442 | } |
443 | |||
450 | #else | 444 | #else |
451 | static inline void rangetr_hash_eval(struct hashtab *h) | 445 | static inline void hash_eval(struct hashtab *h, char *hash_name) |
452 | { | 446 | { |
453 | } | 447 | } |
454 | #endif | 448 | #endif |
@@ -1802,7 +1796,7 @@ static int range_read(struct policydb *p, void *fp) | |||
1802 | rt = NULL; | 1796 | rt = NULL; |
1803 | r = NULL; | 1797 | r = NULL; |
1804 | } | 1798 | } |
1805 | rangetr_hash_eval(p->range_tr); | 1799 | hash_eval(p->range_tr, "rangetr"); |
1806 | rc = 0; | 1800 | rc = 0; |
1807 | out: | 1801 | out: |
1808 | kfree(rt); | 1802 | kfree(rt); |