]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream/segments: remove RB_MIN/RB_MAX
authorVictor Julien <victor@inliniac.net>
Tue, 28 Aug 2018 09:50:23 +0000 (11:50 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 17 Sep 2018 06:27:24 +0000 (08:27 +0200)
src/stream-tcp-list.c

index 1b6799b40a938fb1fadd3a7f672f50ed67cadf56..49e3c49e46ecf7b2c7dd2e92158938eeba114186 100644 (file)
@@ -521,16 +521,19 @@ static int DoHandleData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
         handle = tree_seg;
     }
 
+    const bool is_head = !(TCPSEG_RB_PREV(handle));
+    const bool is_tail = !(TCPSEG_RB_NEXT(handle));
+
     /* new list head  */
-    if (handle == RB_MIN(TCPSEG, &stream->seg_tree) && TCPSEG_RB_NEXT(handle)) {
+    if (is_head && !is_tail) {
         result = DoHandleDataCheckForward(stream, handle, buf, p);
 
     /* new list tail */
-    } else if (handle == RB_MAX(TCPSEG, &stream->seg_tree) && TCPSEG_RB_PREV(handle)) {
+    } else if (!is_head && is_tail) {
         result = DoHandleDataCheckBackwards(stream, handle, buf, p);
 
     /* middle of the list */
-    } else if (TCPSEG_RB_NEXT(handle) && TCPSEG_RB_PREV(handle)) {
+    } else if (!is_head && !is_tail) {
         result = DoHandleDataCheckBackwards(stream, handle, buf, p);
         result |= DoHandleDataCheckForward(stream, handle, buf, p);
     }