Author: Tj <debian@iam.tj>
Last-Update: 2025-09-27
Forwarded: not-needed
Description: Fix C23 pointer-to-integer cast bugs

diff --git a/include/libast/types.h b/include/libast/types.h
index e9d4dbe..9dabaf3 100644
--- a/include/libast/types.h.in
+++ b/include/libast/types.h.in
@@ -290,6 +290,7 @@
  * @ingroup DOXGRP_TYPES
  */
 
+#define SPIF_ZERO_TYPE(type)             (SPIF_CAST(type) (0))
 /**
  * Returns a NULL object of the specified base type.
  *
diff --git a/src/array.c b/src/array.c
index 8dde32d..2bcfd5c 100644
--- a/src/array.c
+++ b/src/array.c
@@ -447,7 +447,7 @@ spif_array_vector_contains(spif_array_t self, spif_obj_t obj)
 static spif_listidx_t
 spif_array_count(spif_array_t self)
 {
-    ASSERT_RVAL(!SPIF_ARRAY_ISNULL(self), SPIF_NULL_TYPE(listidx));
+    ASSERT_RVAL(!SPIF_ARRAY_ISNULL(self), SPIF_ZERO_TYPE(listidx));
     return self->len;
 }
 
diff --git a/src/builtin_hashes.c b/src/builtin_hashes.c
index 7de999a..652b3b4 100644
--- a/src/builtin_hashes.c
+++ b/src/builtin_hashes.c
@@ -26,6 +26,7 @@ static const char __attribute__((unused)) cvs_ident[] = "$Id: builtin_hashes.c,v
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
+#include <stdint.h>
 
 #include <libast_internal.h>
 
@@ -178,7 +179,7 @@ spifhash_jenkinsLE(register spif_uint8_t *key, register spif_uint32_t length, re
 
     /* The loop below handles most of the key (all but the last
        length % 12 bytes). */
-    if ((SPIF_CAST(uint32) key) & 3) {
+    if (((uintptr_t) key) % 32 != 0) {
         /* Not 32-bit aligned.  Use old method. */
         while (len >= 12) {
             a += (key[0] + (SPIF_CAST(uint32) key[1] << 8) + (SPIF_CAST(uint32) key[2] << 16) + (SPIF_CAST(uint32) key[3] << 24));
diff --git a/src/linked_list.c b/src/linked_list.c
index 53a3425..748b9de 100644
--- a/src/linked_list.c
+++ b/src/linked_list.c
@@ -564,7 +564,7 @@ spif_linked_list_vector_contains(spif_linked_list_t self, spif_obj_t obj)
 static spif_listidx_t
 spif_linked_list_count(spif_linked_list_t self)
 {
-    ASSERT_RVAL(!SPIF_LIST_ISNULL(self), SPIF_NULL_TYPE(listidx));
+    ASSERT_RVAL(!SPIF_LIST_ISNULL(self), SPIF_ZERO_TYPE(listidx));
     return self->len;
 }
 
diff --git a/src/socket.c b/src/socket.c
index da601b4..bd9ad70 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -760,7 +760,7 @@ spif_url_get_portnum(spif_url_t self)
 {
     spif_str_t port_str;
 
-    ASSERT_RVAL(!SPIF_URL_ISNULL(self), SPIF_NULL_TYPE(sockport));
+    ASSERT_RVAL(!SPIF_URL_ISNULL(self), SPIF_ZERO_TYPE(sockport));
 
     /* Return the integer form of the port number for a URL */
     port_str = spif_url_get_port(self);
