From: Victor Julien Date: Fri, 12 Jan 2024 12:41:17 +0000 (+0100) Subject: detect/alert: minor loop cleanup X-Git-Tag: suricata-8.0.0-beta1~1181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f72a04973764ea849096cec3ee828e7ce4891ec;p=thirdparty%2Fsuricata.git detect/alert: minor loop cleanup --- diff --git a/src/detect-engine-alert.c b/src/detect-engine-alert.c index e0854c3782..bf6a760b88 100644 --- a/src/detect-engine-alert.c +++ b/src/detect-engine-alert.c @@ -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