]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util: fix -Wshorten-64-to-32 warnings for afpacket
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 22 May 2025 12:59:16 +0000 (14:59 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 10 Jun 2025 20:13:55 +0000 (22:13 +0200)
Ticket: #6186

src/runmode-af-packet.c
src/source-af-packet.c
src/threads.h
src/util-systemd.c

index 93746a2fbe7f071532fd086e2f711f4a7b645baa..940eece3a0e85f9ddc4349e5315cc1adcbb8a058 100644 (file)
@@ -597,12 +597,12 @@ static void *ParseAFPConfig(const char *iface)
     }
 
     if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "buffer-size", &value)) == 1) {
-        aconf->buffer_size = value;
+        aconf->buffer_size = (int)value;
     } else {
         aconf->buffer_size = 0;
     }
     if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "ring-size", &value)) == 1) {
-        aconf->ring_size = value;
+        aconf->ring_size = (int)value;
     }
 
     if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "block-size", &value)) == 1) {
@@ -610,12 +610,12 @@ static void *ParseAFPConfig(const char *iface)
             SCLogWarning("%s: block-size %" PRIuMAX " must be a multiple of pagesize (%u).", iface,
                     value, getpagesize());
         } else {
-            aconf->block_size = value;
+            aconf->block_size = (int)value;
         }
     }
 
     if ((SCConfGetChildValueIntWithDefault(if_root, if_default, "block-timeout", &value)) == 1) {
-        aconf->block_timeout = value;
+        aconf->block_timeout = (int)value;
     } else {
         aconf->block_timeout = 10;
     }
@@ -625,7 +625,7 @@ static void *ParseAFPConfig(const char *iface)
             SCLogWarning("%s: v2-block-size %" PRIuMAX " must be a multiple of pagesize (%u).",
                     iface, value, getpagesize());
         } else {
-            aconf->v2_block_size = value;
+            aconf->v2_block_size = (int)value;
         }
     }
 
index 427c9f717fcf81f2ae739b744b63ba1dff81791e..e5c2c23fc4c1b5f13c70463678816b831154454f 100644 (file)
@@ -2744,7 +2744,7 @@ static void UpdateRawDataForVLANHdr(Packet *p)
 {
     if (p->afp_v.vlan_tci != 0) {
         uint8_t *pstart = GET_PKT_DATA(p) - VLAN_HEADER_LEN;
-        size_t plen = GET_PKT_LEN(p) + VLAN_HEADER_LEN;
+        uint32_t plen = GET_PKT_LEN(p) + VLAN_HEADER_LEN;
         /* move ethernet addresses */
         memmove(pstart, GET_PKT_DATA(p), 2 * ETH_ALEN);
         /* write vlan info */
index e2b0daa07c47e0d9c4968a03b85a485f10103a7f..b16848f034c381919977dc01eea0f77484fb237a 100644 (file)
@@ -252,12 +252,13 @@ enum {
 })
 
 #else
-#define SCGetThreadIdLong(...) ({ \
-   pid_t tmpthid; \
-   tmpthid = syscall(SYS_gettid); \
-   unsigned long _scgetthread_tid = (unsigned long)tmpthid; \
-   _scgetthread_tid; \
-})
+#define SCGetThreadIdLong(...)                                                                     \
+    ({                                                                                             \
+        pid_t tmpthid;                                                                             \
+        tmpthid = (pid_t)syscall(SYS_gettid);                                                      \
+        unsigned long _scgetthread_tid = (unsigned long)tmpthid;                                   \
+        _scgetthread_tid;                                                                          \
+    })
 #endif /* OS FREEBSD */
 
 extern thread_local char t_thread_name[THREAD_NAME_LEN + 1];
index ad2b0ae4fa2e0085ebc9e6e8cd7ebe8da3de3eb4..cfa51c0c4ad4e91e1d74196e83ebd5b085188abb 100644 (file)
@@ -74,7 +74,8 @@ static int Notify(const char *message)
     if (fd < 0)
         return -errno;
 
-    if (connect(fd, &socket_addr.sa, offsetof(struct sockaddr_un, sun_path) + path_length) != 0)
+    if (connect(fd, &socket_addr.sa,
+                offsetof(struct sockaddr_un, sun_path) + (uint32_t)path_length) != 0)
         return -errno;
 
     ssize_t written = write(fd, message, message_length);