Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning integers 64to32 6186 v20.2 #11416

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/counters.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,9 @@ static uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen)
{
CountersIdType *t = (CountersIdType *)data;
uint32_t hash = 0;
int len = strlen(t->string);
size_t len = strlen(t->string);

for (int i = 0; i < len; i++)
for (size_t i = 0; i < len; i++)
hash += u8_tolower((unsigned char)t->string[i]);

hash = hash % ht->array_size;
Expand All @@ -1054,8 +1054,8 @@ static char CountersIdHashCompareFunc(void *data1, uint16_t datalen1,
{
CountersIdType *t1 = (CountersIdType *)data1;
CountersIdType *t2 = (CountersIdType *)data2;
int len1 = 0;
int len2 = 0;
size_t len1 = 0;
size_t len2 = 0;

if (t1 == NULL || t2 == NULL)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/decode-teredo.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int DecodeTeredo(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,

if (len == IPV6_HEADER_LEN +
IPV6_GET_RAW_PLEN(thdr) + (start - pkt)) {
int blen = len - (start - pkt);
uint32_t blen = len - (uint32_t)(start - pkt);
/* spawn off tunnel packet */
Packet *tp = PacketTunnelPktSetup(tv, dtv, p, start, blen,
DECODE_TUNNEL_IPV6_TEREDO);
Expand Down
4 changes: 2 additions & 2 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ inline int PacketCopyDataOffset(Packet *p, uint32_t offset, const uint8_t *data,
*/
inline int PacketCopyData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
{
SET_PKT_LEN(p, (size_t)pktlen);
SET_PKT_LEN(p, pktlen);
return PacketCopyDataOffset(p, 0, pktdata, pktlen);
}

Expand Down Expand Up @@ -810,7 +810,7 @@ void DecodeThreadVarsFree(ThreadVars *tv, DecodeThreadVars *dtv)
*/
inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen)
{
SET_PKT_LEN(p, (size_t)pktlen);
SET_PKT_LEN(p, pktlen);
if (unlikely(!pktdata)) {
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/feature.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ static uint32_t FeatureHashFunc(HashListTable *ht, void *data,
{
FeatureEntryType *f = (FeatureEntryType *)data;
uint32_t hash = 0;
int len = strlen(f->feature);
size_t len = strlen(f->feature);

for (int i = 0; i < len; i++)
for (size_t i = 0; i < len; i++)
hash += u8_tolower((unsigned char)f->feature[i]);

return (hash % ht->array_size);
Expand All @@ -55,8 +55,8 @@ static char FeatureHashCompareFunc(void *data1, uint16_t datalen1,
{
FeatureEntryType *f1 = (FeatureEntryType *)data1;
FeatureEntryType *f2 = (FeatureEntryType *)data2;
int len1 = 0;
int len2 = 0;
size_t len1 = 0;
size_t len2 = 0;

if (f1 == NULL || f2 == NULL)
return 0;
Expand Down
5 changes: 3 additions & 2 deletions src/flow-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static uint32_t FlowTimeoutHash(FlowManagerTimeoutThread *td, SCTime_t ts, const
#define TYPE uint32_t
#endif

const uint32_t ts_secs = SCTIME_SECS(ts);
const time_t ts_secs = SCTIME_SECS(ts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second tracking in the flow engine is currently all u32, so I would suggest leaving this as u32 until we want to move it to a larger type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

for (uint32_t idx = hash_min; idx < hash_max; idx+=BITS) {
TYPE check_bits = 0;
const uint32_t check = MIN(BITS, (hash_max - idx));
Expand Down Expand Up @@ -949,7 +949,8 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
gettimeofday(&cond_tv, NULL);
struct timeval add_tv;
add_tv.tv_sec = 0;
add_tv.tv_usec = (sleep_per_wu * 1000);
DEBUG_VALIDATE_BUG_ON(sleep_per_wu > UINT32_MAX / 1000);
add_tv.tv_usec = (uint32_t)(sleep_per_wu * 1000);
timeradd(&cond_tv, &add_tv, &cond_tv);

struct timespec cond_time = FROM_TIMEVAL(cond_tv);
Expand Down
Loading