]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: use bool wherever possible
authorShivani Bhardwaj <shivani@oisf.net>
Sat, 15 Mar 2025 09:41:34 +0000 (15:11 +0530)
committerVictor Julien <victor@inliniac.net>
Sat, 29 Mar 2025 05:37:59 +0000 (06:37 +0100)
src/stream-tcp-reassemble.c
src/stream-tcp-reassemble.h

index a1685d4d1572d6c4de8e22d1cd33801ac76c88f6..3526245639400e6a1e531a6a15c7ef32cbdac4da 100644 (file)
@@ -619,10 +619,10 @@ static void StreamTcpReassembleExceptionPolicyStatsIncr(
  *
  *  \param p packet with *LOCKED* flow
  *
- *  \retval 1 stream has depth reached
- *  \retval 0 stream does not have depth reached
+ *  \retval true stream has depth reached
+ *  \retval false stream does not have depth reached
  */
-int StreamTcpReassembleDepthReached(Packet *p)
+bool StreamTcpReassembleDepthReached(Packet *p)
 {
     if (p->flow != NULL && p->flow->protoctx != NULL) {
         TcpSession *ssn = p->flow->protoctx;
@@ -633,10 +633,10 @@ int StreamTcpReassembleDepthReached(Packet *p)
             stream = &ssn->server;
         }
 
-        return (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) ? 1 : 0;
+        return (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) ? true : false;
     }
 
-    return 0;
+    return false;
 }
 
 /**
@@ -914,11 +914,11 @@ static uint8_t StreamGetAppLayerFlags(TcpSession *ssn, TcpStream *stream,
 /**
  *  \brief Check the minimum size limits for reassembly.
  *
- *  \retval 0 don't reassemble yet
- *  \retval 1 do reassemble
+ *  \retval false don't reassemble yet
+ *  \retval true do reassemble
  */
-static int StreamTcpReassembleRawCheckLimit(const TcpSession *ssn,
-        const TcpStream *stream, const Packet *p)
+static bool StreamTcpReassembleRawCheckLimit(
+        const TcpSession *ssn, const TcpStream *stream, const Packet *p)
 {
     SCEnter();
 
@@ -940,16 +940,16 @@ static int StreamTcpReassembleRawCheckLimit(const TcpSession *ssn,
             SCLogDebug("reassembling now as STREAMTCP_STREAM_FLAG_NEW_RAW_DISABLED is set, "
                     "so no new segments will be considered");
         }
-        SCReturnInt(1);
+        SCReturnBool(true);
     }
 #undef STREAMTCP_STREAM_FLAG_FLUSH_FLAGS
 
     /* some states mean we reassemble no matter how much data we have */
     if (ssn->state > TCP_TIME_WAIT)
-        SCReturnInt(1);
+        SCReturnBool(true);
 
     if (p->flags & PKT_PSEUDO_STREAM_END)
-        SCReturnInt(1);
+        SCReturnBool(true);
 
     const uint64_t last_ack_abs = GetAbsLastAck(stream);
     int64_t diff = last_ack_abs - STREAM_RAW_PROGRESS(stream);
@@ -958,17 +958,17 @@ static int StreamTcpReassembleRawCheckLimit(const TcpSession *ssn,
 
     /* check if we have enough data to do raw reassembly */
     if (chunk_size <= diff) {
-        SCReturnInt(1);
+        SCReturnBool(true);
     } else {
         SCLogDebug("%s min chunk len not yet reached: "
                    "last_ack %" PRIu32 ", ra_raw_base_seq %" PRIu32 ", %" PRIu32 " < "
                    "%" PRIi64,
                 PKT_IS_TOSERVER(p) ? "toserver" : "toclient", stream->last_ack, stream->base_seq,
                 (stream->last_ack - stream->base_seq), chunk_size);
-        SCReturnInt(0);
+        SCReturnBool(false);
     }
 
-    SCReturnInt(0);
+    SCReturnBool(false);
 }
 
 /**
index 97dac28e2b5732608380b2c80e6a4c84934712ce..75bb5cc46d56a6441e52acf4c01a04d1a1df4eba 100644 (file)
@@ -123,7 +123,7 @@ void StreamTcpSegmentReturntoPool(TcpSegment *);
 void StreamTcpReassembleTriggerRawReassembly(TcpSession *, int direction);
 
 void StreamTcpPruneSession(Flow *, uint8_t);
-int StreamTcpReassembleDepthReached(Packet *p);
+bool StreamTcpReassembleDepthReached(Packet *p);
 
 void StreamTcpReassembleIncrMemuse(uint64_t size);
 void StreamTcpReassembleDecrMemuse(uint64_t size);