]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/alert: minor loop cleanup
authorVictor Julien <vjulien@oisf.net>
Fri, 12 Jan 2024 12:41:17 +0000 (13:41 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 2 Jul 2024 19:25:29 +0000 (21:25 +0200)
(cherry picked from commit 8f72a04973764ea849096cec3ee828e7ce4891ec)

src/detect-engine-alert.c

index 39ce79818c8017ac16f9e7a153e37d9ff2f69080..b6d690aff85e7627727458335abdad46f353a24b 100644 (file)
@@ -377,10 +377,7 @@ void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx
     qsort(det_ctx->alert_queue, det_ctx->alert_queue_size, sizeof(PacketAlert),
             AlertQueueSortHelper);
 
-    uint16_t i = 0;
-    uint16_t max_pos = det_ctx->alert_queue_size;
-
-    while (i < max_pos) {
+    for (uint16_t i = 0; i < det_ctx->alert_queue_size; i++) {
         PacketAlert *pa = &det_ctx->alert_queue[i];
         const Signature *s = de_ctx->sig_array[pa->num];
         int res = PacketAlertHandle(de_ctx, det_ctx, s, p, pa);
@@ -421,13 +418,13 @@ void PacketAlertFinalize(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx
 
             /* pass "alert" found, we're done */
             if (pa->action & ACTION_PASS) {
+                SCLogDebug("sid:%u: is a pass rule, so break out of loop", s->id);
                 break;
             }
             p->alerts.cnt++;
         } else {
             p->alerts.discarded++;
         }
-        i++;
     }
 
     /* At this point, we should have all the new alerts. Now check the tag