From: Philippe Antoine Date: Tue, 18 Jan 2022 09:43:56 +0000 (+0100) Subject: utils: fix integer warnings in r files X-Git-Tag: suricata-7.0.0-beta1~822 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5790280c9535dd9aee450389f73d101be0973ab0;p=thirdparty%2Fsuricata.git utils: fix integer warnings in r files Ticket: 4516 --- diff --git a/src/reputation.c b/src/reputation.c index 47dbeefdad..101f580ae7 100644 --- a/src/reputation.c +++ b/src/reputation.c @@ -77,7 +77,7 @@ static void SRepCIDRFreeUserData(void *data) return; } -static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, int value) +static void SRepCIDRAddNetblock(SRepCIDRTree *cidr_ctx, char *ip, int cat, uint8_t value) { SReputation *user_data = NULL; if ((user_data = SCMalloc(sizeof(SReputation))) == NULL) { @@ -309,11 +309,11 @@ static int SRepSplitLine(SRepCIDRTree *cidr_ctx, char *line, Address *ip, uint8_ if (strcmp(ptrs[0], "ip") == 0) return 1; - int c, v; - if (StringParseI32RangeCheck(&c, 10, 0, (const char *)ptrs[1], 0, SREP_MAX_CATS - 1) < 0) + uint8_t c, v; + if (StringParseU8RangeCheck(&c, 10, 0, (const char *)ptrs[1], 0, SREP_MAX_CATS - 1) < 0) return -1; - if (StringParseI32RangeCheck(&v, 10, 0, (const char *)ptrs[2], 0, SREP_MAX_VAL) < 0) + if (StringParseU8RangeCheck(&v, 10, 0, (const char *)ptrs[2], 0, SREP_MAX_VAL) < 0) return -1; if (strchr(ptrs[0], '/') != NULL) { diff --git a/src/respond-reject-libnet11.c b/src/respond-reject-libnet11.c index f75ab27335..4c7be9dfb5 100644 --- a/src/respond-reject-libnet11.c +++ b/src/respond-reject-libnet11.c @@ -80,7 +80,7 @@ typedef struct Libnet11Packet_ { struct libnet_in6_addr src6, dst6; uint32_t src4, dst4; uint16_t sp, dp; - size_t len; + uint16_t len; uint8_t *smac, *dmac; } Libnet11Packet; @@ -351,7 +351,7 @@ int RejectSendLibnet11IPv4ICMP(ThreadVars *tv, Packet *p, void *data, enum Rejec lpacket.id = 0; lpacket.flow = 0; lpacket.class = 0; - const int iplen = IPV4_GET_IPLEN(p); + const uint16_t iplen = IPV4_GET_IPLEN(p); if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + LIBNET_IPV4_H + 8) { lpacket.len = MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, (LIBNET_IPV4_H + iplen)); } else { @@ -493,7 +493,7 @@ int RejectSendLibnet11IPv6ICMP(ThreadVars *tv, Packet *p, void *data, enum Rejec lpacket.id = 0; lpacket.flow = 0; lpacket.class = 0; - const int iplen = IPV6_GET_PLEN(p); + const uint16_t iplen = IPV6_GET_PLEN(p); if (g_reject_dev_mtu >= ETHERNET_HEADER_LEN + IPV6_HEADER_LEN + 8) { lpacket.len = IPV6_HEADER_LEN + MIN(g_reject_dev_mtu - ETHERNET_HEADER_LEN, iplen); } else { diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index 27ef207606..fca4bc9c84 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -210,7 +210,7 @@ int RunModeErfFileAutoFp(void) TmSlotSetFuncAppend(tv_detect_ncpu, tm_module, NULL); if (threading_set_cpu_affinity) { - TmThreadSetCPUAffinity(tv_detect_ncpu, (int)cpu); + TmThreadSetCPUAffinity(tv_detect_ncpu, cpu); /* If we have more than one core/cpu, the first Detect thread * (at cpu 0) will have less priority (higher 'nice' value) * In this case we will set the thread priority to +10 (default is 0) diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index f4bbe1e659..29f2264f58 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -808,7 +808,7 @@ TmEcode UnixSocketRegisterTenantHandler(json_t *cmd, json_t* answer, void *data) } SCLogInfo("VLAN handler: id %u maps to tenant %u", (uint32_t)traffic_id, tenant_id); - r = DetectEngineTentantRegisterVlanId(tenant_id, (uint32_t)traffic_id); + r = DetectEngineTentantRegisterVlanId(tenant_id, (uint16_t)traffic_id); } if (r != 0) { json_object_set_new(answer, "message", json_string("handler setup failure")); @@ -889,7 +889,7 @@ TmEcode UnixSocketUnregisterTenantHandler(json_t *cmd, json_t* answer, void *dat } SCLogInfo("VLAN handler: removing mapping of %u to tenant %u", (uint32_t)traffic_id, tenant_id); - r = DetectEngineTentantUnregisterVlanId(tenant_id, (uint32_t)traffic_id); + r = DetectEngineTentantUnregisterVlanId(tenant_id, (uint16_t)traffic_id); } if (r != 0) { json_object_set_new(answer, "message", json_string("handler unregister failure")); diff --git a/src/runmodes.c b/src/runmodes.c index 7188086b19..2aca1b4ac8 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -903,7 +903,7 @@ void RunModeInitializeOutputs(void) } /* register the logger bits to the app-layer */ - int a; + AppProto a; for (a = 0; a < ALPROTO_MAX; a++) { if (logger_bits[a] == 0) continue;