]> 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 <vjulien@oisf.net>
Fri, 7 Jun 2024 18:54:05 +0000 (20:54 +0200)
src/detect-engine-alert.c

index e0854c3782af7373dbb69e0934afddad79148ee9..bf6a760b88974afcd7b6116dfdf9aa8c5673d9d2 100644 (file)
@@ -376,10 +376,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);
@@ -420,13 +417,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