From: Philippe Antoine Date: Thu, 23 Nov 2023 14:46:39 +0000 (+0100) Subject: util: fix -Wshorten-64-to-32 warnings X-Git-Tag: suricata-8.0.0-beta1~1132 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1790aa49a4dad6e7774e8fcd27ac187dd2443d24;p=thirdparty%2Fsuricata.git util: fix -Wshorten-64-to-32 warnings Ticket: 6186 Warnings about downcast from 64 to 32 bits Generic fixes required to get app-layer clean --- diff --git a/src/detect-flow.c b/src/detect-flow.c index 0395b55f00..c268dedb15 100644 --- a/src/detect-flow.c +++ b/src/detect-flow.c @@ -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) { diff --git a/src/suricata-common.h b/src/suricata-common.h index cb95d17e97..2091250e49 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -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)) diff --git a/src/util-streaming-buffer.c b/src/util-streaming-buffer.c index 0497e70769..3b56d8e0d6 100644 --- a/src/util-streaming-buffer.c +++ b/src/util-streaming-buffer.c @@ -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; } diff --git a/src/util-time.h b/src/util-time.h index a2a915039f..a537a9a864 100644 --- a/src/util-time.h +++ b/src/util-time.h @@ -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) \