diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 43accd7217..65b574716f 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -272,12 +272,9 @@ int AppLayerParserSetup(void) void AppLayerParserPostStreamSetup(void) { - AppProto alproto = 0; - int flow_proto = 0; - /* lets set a default value for stream_depth */ - for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { - for (alproto = 0; alproto < ALPROTO_MAX; alproto++) { + for (int flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { + for (AppProto alproto = 0; alproto < ALPROTO_MAX; alproto++) { if (!(alp_ctx.ctxs[flow_proto][alproto].internal_flags & APP_LAYER_PARSER_INT_STREAM_DEPTH_SET)) { alp_ctx.ctxs[flow_proto][alproto].stream_depth = @@ -301,17 +298,12 @@ AppLayerParserThreadCtx *AppLayerParserThreadCtxAlloc(void) { SCEnter(); - AppProto alproto = 0; - uint8_t flow_proto = 0; - AppLayerParserThreadCtx *tctx; - - tctx = SCMalloc(sizeof(*tctx)); + AppLayerParserThreadCtx *tctx = SCCalloc(1, sizeof(*tctx)); if (tctx == NULL) goto end; - memset(tctx, 0, sizeof(*tctx)); - for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { - for (alproto = 0; alproto < ALPROTO_MAX; alproto++) { + for (uint8_t flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { + for (AppProto alproto = 0; alproto < ALPROTO_MAX; alproto++) { uint8_t ipproto = FlowGetReverseProtoMapping(flow_proto); tctx->alproto_local_storage[flow_proto][alproto] = @@ -327,11 +319,8 @@ void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx) { SCEnter(); - AppProto alproto = 0; - uint8_t flow_proto = 0; - - for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { - for (alproto = 0; alproto < ALPROTO_MAX; alproto++) { + for (uint8_t flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { + for (AppProto alproto = 0; alproto < ALPROTO_MAX; alproto++) { uint8_t ipproto = FlowGetReverseProtoMapping(flow_proto); AppLayerParserDestroyProtocolParserLocalStorage(ipproto, alproto, @@ -739,7 +728,7 @@ uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint if (pstate == NULL) SCReturnCT(0ULL, "uint64_t"); - SCReturnCT(pstate->inspect_id[direction & STREAM_TOSERVER ? 0 : 1], "uint64_t"); + SCReturnCT(pstate->inspect_id[(direction & STREAM_TOSERVER) ? 0 : 1], "uint64_t"); } static inline uint64_t GetTxDetectFlags(AppLayerTxData *txd, const uint8_t dir) @@ -1172,7 +1161,7 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f, uint64_t active_id; uint64_t log_id = pstate->log_id; - uint64_t inspect_id = pstate->inspect_id[direction & STREAM_TOSERVER ? 0 : 1]; + uint64_t inspect_id = pstate->inspect_id[(direction & STREAM_TOSERVER) ? 0 : 1]; if (alp_ctx.ctxs[f->protomap][f->alproto].logger == true) { active_id = MIN(log_id, inspect_id); } else { diff --git a/src/app-layer.c b/src/app-layer.c index f7c55dcf70..eb4ce8aca4 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -308,9 +308,8 @@ failure: return; } -static int TCPProtoDetectTriggerOpposingSide(ThreadVars *tv, - TcpReassemblyThreadCtx *ra_ctx, - Packet *p, TcpSession *ssn, TcpStream *stream) +static int TCPProtoDetectTriggerOpposingSide(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, + Packet *p, TcpSession *ssn, const TcpStream *stream) { TcpStream *opposing_stream = NULL; if (stream == &ssn->client) { @@ -985,7 +984,7 @@ void AppLayerRegisterGlobalCounters(void) #define IPPROTOS_MAX 2 void AppLayerSetupCounters() { - uint8_t ipprotos[] = { IPPROTO_TCP, IPPROTO_UDP }; + const uint8_t ipprotos[] = { IPPROTO_TCP, IPPROTO_UDP }; AppProto alprotos[ALPROTO_MAX]; const char *str = "app_layer.flow."; const char *estr = "app_layer.error."; @@ -1065,7 +1064,7 @@ void AppLayerSetupCounters() void AppLayerRegisterThreadCounters(ThreadVars *tv) { - uint8_t ipprotos[] = { IPPROTO_TCP, IPPROTO_UDP }; + const uint8_t ipprotos[] = { IPPROTO_TCP, IPPROTO_UDP }; AppProto alprotos[ALPROTO_MAX]; AppLayerProtoDetectSupportedAppProtocols(alprotos);