]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
log-pcap: remove redundant check 7369/head
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 09:36:21 +0000 (11:36 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 3 May 2022 11:30:21 +0000 (13:30 +0200)
Check is always true but confuses cppcheck:

src/log-pcap.c:1224:32: warning: Either the condition 'filename' is redundant or there is possible null pointer dereference: filename. [nullPointerRedundantCheck]
    if ((pl->prefix = SCStrdup(filename)) == NULL) {
                               ^
src/log-pcap.c:1421:9: note: Assuming that condition 'filename' is not redundant
    if (filename) {
        ^
src/log-pcap.c:1224:32: note: Null pointer dereference
    if ((pl->prefix = SCStrdup(filename)) == NULL) {
                               ^

Bug: #5291.
(cherry picked from commit 3dfbf0bf1124aab7c7060f46b364877ab25455ee)

src/log-pcap.c

index 07ac49452c5be2c81ea7572b82d67011c0e89917..28a74843caf9f095d25ca3a7c0c182e33c24f1d9 100644 (file)
@@ -1420,10 +1420,8 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf)
                 compression_str ? compression_str : "none");
     }
 
-    if (filename) {
-        if (ParseFilename(pl, filename) != 0)
-            exit(EXIT_FAILURE);
-    }
+    if (ParseFilename(pl, filename) != 0)
+        exit(EXIT_FAILURE);
 
     SCLogInfo("using %s logging", pl->mode == LOGMODE_SGUIL ?
               "Sguil compatible" : (pl->mode == LOGMODE_MULTI ? "multi" : "normal"));