]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: minor code cleanup
authorVictor Julien <victor@inliniac.net>
Mon, 16 Mar 2020 21:25:49 +0000 (22:25 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Mar 2020 21:03:23 +0000 (22:03 +0100)
src/app-layer.c

index 25264543c462f7d104e958854b76cc1d444f84b8..e69db23cf9f9b6599dd7025d035cf1dfe3988950 100644 (file)
@@ -294,7 +294,10 @@ static int TCPProtoDetectTriggerOpposingSide(ThreadVars *tv,
     return ret;
 }
 
-/** \todo data const */
+/** \todo data const
+ *  \retval int -1 error
+ *  \retval int 0 ok
+ */
 static int TCPProtoDetect(ThreadVars *tv,
         TcpReassemblyThreadCtx *ra_ctx, AppLayerThreadCtx *app_tctx,
         Packet *p, Flow *f, TcpSession *ssn, TcpStream **stream,
@@ -393,7 +396,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                         p, ssn, *stream) != 0)
             {
                 DisableAppLayer(tv, f, p);
-                goto failure;
+                SCReturnInt(-1);
             }
         }
 
@@ -421,7 +424,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                 AppLayerDecoderEventsSetEventRaw(&p->app_layer_events,
                         APPLAYER_WRONG_DIRECTION_FIRST_DATA);
                 DisableAppLayer(tv, f, p);
-                goto failure;
+                SCReturnInt(-1);
             }
             /* This can happen if the current direction is not the
              * right direction, and the data from the other(also
@@ -436,7 +439,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                 FLOW_RESET_PP_DONE(f, flags);
                 FLOW_RESET_PM_DONE(f, flags);
                 FLOW_RESET_PE_DONE(f, flags);
-                goto failure;
+                SCReturnInt(-1);
             }
         }
 
@@ -449,7 +452,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                 flags, data, data_len);
         PACKET_PROFILING_APP_END(app_tctx, f->alproto);
         if (r < 0) {
-            goto failure;
+            SCReturnInt(-1);
         } else if (r == 0) {
             StreamTcpUpdateAppLayerProgress(ssn, direction, data_len);
         }
@@ -475,7 +478,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                 SCLogDebug("midstream end pd %p", ssn);
                 /* midstream and toserver detection failed: give up */
                 DisableAppLayer(tv, f, p);
-                goto end;
+                SCReturnInt(0);
             }
         }
 
@@ -502,7 +505,7 @@ static int TCPProtoDetect(ThreadVars *tv,
                     (first_data_dir) && !(first_data_dir & flags))
             {
                 DisableAppLayer(tv, f, p);
-                goto failure;
+                SCReturnInt(-1);
             }
 
             /* if protocol detection is marked done for our direction we
@@ -533,8 +536,9 @@ static int TCPProtoDetect(ThreadVars *tv,
                     *alproto = *alproto_otherdir;
                     SCLogDebug("packet %"PRIu64": pd done(us %u them %u), parser called (r==%d), APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION set",
                             p->pcap_cnt, *alproto, *alproto_otherdir, r);
-                    if (r < 0)
-                        goto failure;
+                    if (r < 0) {
+                        SCReturnInt(-1);
+                    }
                 }
                 *alproto = ALPROTO_FAILED;
                 StreamTcpSetStreamFlagAppProtoDetectionCompleted(*stream);
@@ -547,11 +551,7 @@ static int TCPProtoDetect(ThreadVars *tv,
             TCPProtoDetectCheckBailConditions(tv, f, ssn, p);
         }
     }
-end:
-    return 0;
-
-failure:
-    return -1;
+    SCReturnInt(0);
 }
 
 /** \brief handle TCP data for the app-layer.