]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util: fix -Wshorten-64-to-32 warnings
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 23 Nov 2023 14:46:39 +0000 (15:46 +0100)
committerVictor Julien <victor@inliniac.net>
Sat, 22 Jun 2024 13:54:25 +0000 (15:54 +0200)
Ticket: 6186

Warnings about downcast from 64 to 32 bits

Generic fixes required to get app-layer clean

src/detect-flow.c
src/suricata-common.h
src/util-streaming-buffer.c
src/util-time.h

index 0395b55f0018ac89358e9672b3097624415c23dc..c268dedb155f474b532eaf07f938ed1f3ddd68ca 100644 (file)
@@ -340,8 +340,8 @@ int DetectFlowSetupImplicit(Signature *s, uint32_t flags)
     BUG_ON(flags & ~SIG_FLAG_BOTH);
     BUG_ON((flags & SIG_FLAG_BOTH) == SIG_FLAG_BOTH);
 
-    SCLogDebug("want %08lx", flags & SIG_FLAG_BOTH);
-    SCLogDebug("have %08lx", s->flags & SIG_FLAG_BOTH);
+    SCLogDebug("want %08x", flags & SIG_FLAG_BOTH);
+    SCLogDebug("have %08x", s->flags & SIG_FLAG_BOTH);
 
     if (flags & SIG_FLAG_TOSERVER) {
         if ((s->flags & SIG_FLAG_BOTH) == SIG_FLAG_BOTH) {
index cb95d17e974fd55cfb01c5c665caf3aff1267712..2091250e49c5aba5a595a195f3126d0fd13216c0 100644 (file)
@@ -397,7 +397,7 @@ typedef unsigned char u_char;
 
 #define BIT_U8(n)  ((uint8_t)(1 << (n)))
 #define BIT_U16(n) ((uint16_t)(1 << (n)))
-#define BIT_U32(n) (1UL  << (n))
+#define BIT_U32(n) ((uint32_t)(1UL << (n)))
 #define BIT_U64(n) (1ULL << (n))
 
 #define WARN_UNUSED __attribute__((warn_unused_result))
index 0497e70769b6f274860e207811d7dfe40e49aa50..3b56d8e0d652b4c2eb69f4eade137351f4ebaaea 100644 (file)
@@ -710,7 +710,7 @@ static inline int WARN_UNUSED GrowRegionToSize(StreamingBuffer *sb,
     if (size > BIT_U32(30)) { // 1GiB
         if (!g2s_warn_once) {
             SCLogWarning("StreamingBuffer::GrowRegionToSize() tried to alloc %u bytes, exceeds "
-                         "limit of %lu",
+                         "limit of %" PRIu32,
                     size, BIT_U32(30));
             g2s_warn_once = true;
         }
index a2a915039fbb4f3638dd2714273d313955c90d93..a537a9a864125e06d7585b83c00ff6b3182357be 100644 (file)
@@ -53,8 +53,8 @@ typedef struct {
     {                                                                                              \
         .secs = 0, .usecs = 0                                                                      \
     }
-#define SCTIME_USECS(t)          ((uint64_t)(t).usecs)
-#define SCTIME_SECS(t)           ((uint64_t)(t).secs)
+#define SCTIME_USECS(t)          ((t).usecs)
+#define SCTIME_SECS(t)           ((t).secs)
 #define SCTIME_MSECS(t)          (SCTIME_SECS(t) * 1000 + SCTIME_USECS(t) / 1000)
 #define SCTIME_ADD_USECS(ts, us)                                                                   \
     (SCTime_t)                                                                                     \