Rebase on upstream commit 32611aea6543 See $ cd SELinuxProject/selinux $ git log --pretty=oneline libsepol-3.2..32611aea6543 -- libsepol
69 lines
2.3 KiB
Diff
69 lines
2.3 KiB
Diff
From 2723b8ec2a84488f00199687d27d1aae5a76c33b Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
|
Date: Tue, 8 Jun 2021 17:59:07 +0200
|
|
Subject: [PATCH] libsepol/cil: drop unnecessary casts
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
`const_hashtab_key_t` is a typedef of `const char *`, so these casts are
|
|
not needed.
|
|
|
|
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
|
|
Acked-by: James Carter <jwcart2@gmail.com>
|
|
---
|
|
libsepol/cil/src/cil_strpool.c | 15 ++++++---------
|
|
1 file changed, 6 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/libsepol/cil/src/cil_strpool.c b/libsepol/cil/src/cil_strpool.c
|
|
index 70bca3630220..e32ee4e90f34 100644
|
|
--- a/libsepol/cil/src/cil_strpool.c
|
|
+++ b/libsepol/cil/src/cil_strpool.c
|
|
@@ -47,14 +47,13 @@ static hashtab_t cil_strpool_tab = NULL;
|
|
|
|
static unsigned int cil_strpool_hash(hashtab_t h, const_hashtab_key_t key)
|
|
{
|
|
- const char *p, *keyp;
|
|
+ const char *p;
|
|
size_t size;
|
|
unsigned int val;
|
|
|
|
val = 0;
|
|
- keyp = (const char*)key;
|
|
- size = strlen(keyp);
|
|
- for (p = keyp; ((size_t) (p - keyp)) < size; p++)
|
|
+ size = strlen(key);
|
|
+ for (p = key; ((size_t) (p - key)) < size; p++)
|
|
val =
|
|
(val << 4 | (val >> (8 * sizeof(unsigned int) - 4))) ^ (*p);
|
|
return val & (h->size - 1);
|
|
@@ -62,9 +61,7 @@ static unsigned int cil_strpool_hash(hashtab_t h, const_hashtab_key_t key)
|
|
|
|
static int cil_strpool_compare(hashtab_t h __attribute__ ((unused)), const_hashtab_key_t key1, const_hashtab_key_t key2)
|
|
{
|
|
- const char *keyp1 = (const char*)key1;
|
|
- const char *keyp2 = (const char*)key2;
|
|
- return strcmp(keyp1, keyp2);
|
|
+ return strcmp(key1, key2);
|
|
}
|
|
|
|
char *cil_strpool_add(const char *str)
|
|
@@ -73,12 +70,12 @@ char *cil_strpool_add(const char *str)
|
|
|
|
pthread_mutex_lock(&cil_strpool_mutex);
|
|
|
|
- strpool_ref = hashtab_search(cil_strpool_tab, (hashtab_key_t)str);
|
|
+ strpool_ref = hashtab_search(cil_strpool_tab, str);
|
|
if (strpool_ref == NULL) {
|
|
int rc;
|
|
strpool_ref = cil_malloc(sizeof(*strpool_ref));
|
|
strpool_ref->str = cil_strdup(str);
|
|
- rc = hashtab_insert(cil_strpool_tab, (hashtab_key_t)strpool_ref->str, strpool_ref);
|
|
+ rc = hashtab_insert(cil_strpool_tab, strpool_ref->str, strpool_ref);
|
|
if (rc != SEPOL_OK) {
|
|
pthread_mutex_unlock(&cil_strpool_mutex);
|
|
cil_log(CIL_ERR, "Failed to allocate memory\n");
|
|
--
|
|
2.32.0
|
|
|