]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: cleanups
authorVictor Julien <victor@inliniac.net>
Wed, 5 Mar 2014 11:17:20 +0000 (12:17 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 2 Apr 2014 11:13:51 +0000 (13:13 +0200)
Clean up AppLayerParserThreadCtxAlloc and AppLayerParserThreadCtxFree.
Both used confusing variables in loops, with the wrong types.

src/app-layer-parser.c

index 858cc7d9bde7ce1fd41efc764ad26b2dd6a53c49..e60211bf2f82531efc84185239adf85a33df9460 100644 (file)
@@ -189,8 +189,8 @@ AppLayerParserThreadCtx *AppLayerParserThreadCtxAlloc(void)
 {
     SCEnter();
 
-    AppProto i = 0;
-    int j = 0;
+    AppProto alproto = 0;
+    int flow_proto = 0;
     AppLayerParserThreadCtx *tctx;
 
     tctx = SCMalloc(sizeof(*tctx));
@@ -198,10 +198,12 @@ AppLayerParserThreadCtx *AppLayerParserThreadCtxAlloc(void)
         goto end;
     memset(tctx, 0, sizeof(*tctx));
 
-    for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
-        for (j = 0; j < ALPROTO_MAX; j++) {
-            tctx->alproto_local_storage[i][j] =
-                AppLayerParserGetProtocolParserLocalStorage(FlowGetReverseProtoMapping(i), j);
+    for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
+        for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
+            uint8_t ipproto = FlowGetReverseProtoMapping(flow_proto);
+
+            tctx->alproto_local_storage[flow_proto][alproto] =
+                AppLayerParserGetProtocolParserLocalStorage(ipproto, alproto);
         }
     }
 
@@ -213,14 +215,15 @@ void AppLayerParserThreadCtxFree(AppLayerParserThreadCtx *tctx)
 {
     SCEnter();
 
-    AppProto i = 0;
-    int j = 0;
+    AppProto alproto = 0;
+    int flow_proto = 0;
+
+    for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
+        for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
+            uint8_t ipproto = FlowGetReverseProtoMapping(flow_proto);
 
-    for (i = 0; i < FLOW_PROTO_DEFAULT; i++) {
-        for (j = 0; j < ALPROTO_MAX; j++) {
-            AppLayerParserDestroyProtocolParserLocalStorage(FlowGetReverseProtoMapping(i),
-                                                            j,
-                                                            tctx->alproto_local_storage[i][j]);
+            AppLayerParserDestroyProtocolParserLocalStorage(ipproto, alproto,
+                                                            tctx->alproto_local_storage[flow_proto][alproto]);
         }
     }