diff mbox series

[15/47] libsemanage: avoid const dropping casts

Message ID 20241111141706.38039-15-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

    sha256.c: In function ‘Sha256Update’:
    sha256.c:197:40: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
      197 |            TransformFunction( Context, (uint8_t*)Buffer );
          |                                        ^
    sha256.c:199:21: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
      199 |            Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
          |                     ^
    sha256.c:207:21: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
      207 |            Buffer = (uint8_t*)Buffer + n;
          |                     ^

    semanage_store.c: In function ‘semanage_get_active_modules_cmp’:
    semanage_store.c:1059:38: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     1059 |         semanage_module_info_t *aa = (semanage_module_info_t *)a;
          |                                      ^
    semanage_store.c:1060:38: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     1060 |         semanage_module_info_t *bb = (semanage_module_info_t *)b;
          |                                      ^

    genhomedircon.c: In function ‘seuser_sort_func’:
    genhomedircon.c:742:40: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
      742 |         const semanage_seuser_t **u1 = (const semanage_seuser_t **) arg1;
          |                                        ^
    genhomedircon.c:743:40: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
      743 |         const semanage_seuser_t **u2 = (const semanage_seuser_t **) arg2;
          |                                        ^

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/genhomedircon.c  | 4 ++--
 libsemanage/src/semanage_store.c | 4 ++--
 libsemanage/src/sha256.c         | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index 61c95f34..34b5ff93 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -741,8 +741,8 @@  static int write_user_context(genhomedircon_settings_t * s, FILE * out,
 
 static int seuser_sort_func(const void *arg1, const void *arg2)
 {
-	const semanage_seuser_t **u1 = (const semanage_seuser_t **) arg1;
-	const semanage_seuser_t **u2 = (const semanage_seuser_t **) arg2;
+	const semanage_seuser_t *const *u1 = (const semanage_seuser_t *const *) arg1;
+	const semanage_seuser_t *const *u2 = (const semanage_seuser_t *const *) arg2;
 	const char *name1 = semanage_seuser_get_name(*u1);
 	const char *name2 = semanage_seuser_get_name(*u2);
 
diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c
index 29bde24a..0684b2e8 100644
--- a/libsemanage/src/semanage_store.c
+++ b/libsemanage/src/semanage_store.c
@@ -1058,8 +1058,8 @@  cleanup:
 /* qsort comparison function for semanage_get_active_modules. */
 static int semanage_get_active_modules_cmp(const void *a, const void *b)
 {
-	semanage_module_info_t *aa = (semanage_module_info_t *)a;
-	semanage_module_info_t *bb = (semanage_module_info_t *)b;
+	const semanage_module_info_t *aa = (const semanage_module_info_t *)a;
+	const semanage_module_info_t *bb = (const semanage_module_info_t *)b;
 
 	return strcmp(aa->name, bb->name);
 }
diff --git a/libsemanage/src/sha256.c b/libsemanage/src/sha256.c
index fe2aeef0..79664138 100644
--- a/libsemanage/src/sha256.c
+++ b/libsemanage/src/sha256.c
@@ -194,9 +194,9 @@  void
     {
         if( Context->curlen == 0 && BufferSize >= BLOCK_SIZE )
         {
-           TransformFunction( Context, (uint8_t*)Buffer );
+           TransformFunction( Context, (const uint8_t*)Buffer );
            Context->length += BLOCK_SIZE * 8;
-           Buffer = (uint8_t*)Buffer + BLOCK_SIZE;
+           Buffer = (const uint8_t*)Buffer + BLOCK_SIZE;
            BufferSize -= BLOCK_SIZE;
         }
         else
@@ -204,7 +204,7 @@  void
            n = MIN( BufferSize, (BLOCK_SIZE - Context->curlen) );
            memcpy( Context->buf + Context->curlen, Buffer, (size_t)n );
            Context->curlen += n;
-           Buffer = (uint8_t*)Buffer + n;
+           Buffer = (const uint8_t*)Buffer + n;
            BufferSize -= n;
            if( Context->curlen == BLOCK_SIZE )
            {