Skip to content

Commit

Permalink
util: fix -Wshorten-64-to-32 warnings
Browse files Browse the repository at this point in the history
Ticket: 6186

Warnings about downcast from 64 to 32 bits

Generic fixes required to get app-layer clean
  • Loading branch information
catenacyber authored and victorjulien committed Jun 22, 2024
1 parent dc043d0 commit 1790aa4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/detect-flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/suricata-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/util-streaming-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/util-time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 1790aa4

Please sign in to comment.