From: Victor Julien Date: Tue, 28 Aug 2018 09:50:23 +0000 (+0200) Subject: stream/segments: remove RB_MIN/RB_MAX X-Git-Tag: suricata-4.1.0-rc2~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4ff33969eb3bc7b7b58b5b8100e1e0e98faf152;p=thirdparty%2Fsuricata.git stream/segments: remove RB_MIN/RB_MAX --- diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 1b6799b40a..49e3c49e46 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -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); }