diff mbox series

[3/5] libsepol: drop unnecessary const discarding casts

Message ID 20220408131054.7957-3-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 9d57ab6c32ee
Headers show
Series [1/5] libsepol/cil: declare file local function pointer static | expand

Commit Message

Christian Göttsche April 8, 2022, 1:10 p.m. UTC
`hashtab_search()` takes a const_hashtab_key_t, alias `const char*` as
second key parameter type.  Do not unnecessarily cast variables of type
`const char*` to hashtab_key_t, alias `char*`.

    policydb.c: In function ‘policydb_string_to_security_class’:
    policydb.c:4164:39: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     4164 |                                       (hashtab_key_t) class_name);
          |                                       ^
    policydb.c: In function ‘policydb_string_to_av_perm’:
    policydb.c:4184:25: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     4184 |                         (hashtab_key_t)perm_name);
          |                         ^
    policydb.c:4193:25: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     4193 |                         (hashtab_key_t)perm_name);
          |                         ^

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/policydb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c
index 5c7e35e8..0c71f09f 100644
--- a/libsepol/src/policydb.c
+++ b/libsepol/src/policydb.c
@@ -4160,7 +4160,7 @@  static sepol_security_class_t policydb_string_to_security_class(
 	class_datum_t *tclass_datum;
 
 	tclass_datum = hashtab_search(policydb->p_classes.table,
-				      (hashtab_key_t) class_name);
+				      class_name);
 	if (!tclass_datum)
 		return 0;
 	return tclass_datum->s.value;
@@ -4180,7 +4180,7 @@  static sepol_access_vector_t policydb_string_to_av_perm(
 
 	perm_datum = (perm_datum_t *)
 			hashtab_search(tclass_datum->permissions.table,
-			(hashtab_key_t)perm_name);
+			perm_name);
 	if (perm_datum != NULL)
 		return UINT32_C(1) << (perm_datum->s.value - 1);
 
@@ -4189,7 +4189,7 @@  static sepol_access_vector_t policydb_string_to_av_perm(
 
 	perm_datum = (perm_datum_t *)
 			hashtab_search(tclass_datum->comdatum->permissions.table,
-			(hashtab_key_t)perm_name);
+			perm_name);
 
 	if (perm_datum != NULL)
 		return UINT32_C(1) << (perm_datum->s.value - 1);