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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`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@xxxxxxxxxxxxxx>
---
 libsepol/src/policydb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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);
-- 
2.35.1




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux