]> git.ipfire.org Git - thirdparty/suricata.git/commit
time: fix warning in timestring creation
authorVictor Julien <vjulien@oisf.net>
Tue, 26 Apr 2022 19:03:42 +0000 (21:03 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 10:18:21 +0000 (12:18 +0200)
commit2f48e432cd4465bbb1f42fe7778fee44a5d0aa47
treeb3c14ff0ef67f8c36e88aaf35acd7302f09cc0b0
parent4fcb8740e7b98eee1b5e65bd66045c9440cef8b6
time: fix warning in timestring creation

cppcheck:

src/util-time.c:255:18: warning: Either the condition 'str!=NULL' is redundant or there is possible null pointer dereference: str. [nullPointerRedundantCheck]
        snprintf(str, size, "ts-error");
                 ^
src/util-time.c:252:48: note: Assuming that condition 'str!=NULL' is not redundant
    if (likely(t != NULL && fmt != NULL && str != NULL)) {
                                               ^
src/util-time.c:255:18: note: Null pointer dereference
        snprintf(str, size, "ts-error");
                 ^

Only `t` could possibly be NULL if `localtime_r` fails elsewhere.

Bug: #5291.
src/util-time.c