]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fastlog: move code to reduce variable scope
authorPhilippe Antoine <contact@catenacyber.fr>
Wed, 30 Oct 2019 08:33:51 +0000 (09:33 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 5 Dec 2019 12:42:37 +0000 (13:42 +0100)
src/alert-fastlog.c

index ca62155a025b6a9d4f70f7f1b1993dcb21c7efe0..7613a37ad177f6a5ec3016c5b0861958ecd636f9 100644 (file)
@@ -141,19 +141,16 @@ int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p)
             action = "[wDrop] ";
         }
 
-        char proto[16] = "";
+        /* Create the alert string without locking. */
+        int size = 0;
         if (likely(decoder_event == 0)) {
+            char proto[16] = "";
             if (SCProtoNameValid(IP_GET_IPPROTO(p)) == TRUE) {
                 strlcpy(proto, known_proto[IP_GET_IPPROTO(p)], sizeof(proto));
             } else {
                 snprintf(proto, sizeof(proto), "PROTO:%03" PRIu32, IP_GET_IPPROTO(p));
             }
-        }
-
-        /* Create the alert string without locking. */
-        int size = 0;
-        if (likely(decoder_event == 0)) {
-            PrintBufferData(alert_buffer, &size, MAX_FASTLOG_ALERT_SIZE, 
+            PrintBufferData(alert_buffer, &size, MAX_FASTLOG_ALERT_SIZE,
                             "%s  %s[**] [%" PRIu32 ":%" PRIu32 ":%"
                             PRIu32 "] %s [**] [Classification: %s] [Priority: %"PRIu32"]"
                             " {%s} %s:%" PRIu32 " -> %s:%" PRIu32 "\n", timebuf, action,