]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
gen/bool: Clarify bool checks
authorJeff Lucovsky <jlucovsky@oisf.net>
Mon, 17 Feb 2025 14:11:03 +0000 (09:11 -0500)
committerVictor Julien <victor@inliniac.net>
Wed, 19 Feb 2025 08:21:34 +0000 (09:21 +0100)
Remove comparisons with true or false with C bools.

30 files changed:
plugins/napatech/util-napatech.c
src/app-layer-parser.c
src/counters.c
src/datasets.c
src/decode-vlan.c
src/detect-content.c
src/detect-engine-frame.c
src/detect-geoip.c
src/detect-parse.c
src/detect.c
src/flow-manager.c
src/flow-queue.c
src/flow-worker.c
src/runmode-af-packet.c
src/source-af-packet.c
src/source-af-xdp.c
src/source-ipfw.c
src/source-nfq.c
src/source-pcap-file.c
src/stream-tcp-list.c
src/stream-tcp.c
src/suricata.c
src/tm-queues.c
src/tm-threads.c
src/tm-threads.h
src/tmqh-packetpool.c
src/util-ebpf.c
src/util-radix-tree-common.h
src/util-streaming-buffer.c
src/util-thash.c

index da63bdd698aa5ac2f9bb2f4fa29be8ebed33ca6d..d9d246413389672214ffb99d8d58dd55e18700b3 100644 (file)
@@ -317,7 +317,7 @@ static uint32_t UpdateStreamStats(ThreadVars *tv, NtInfoStream_t hInfo, NtStatSt
 
             for (uint32_t hbCount = 0; hbCount < hStat.u.usageData_v0.data.numHostBufferUsed;
                     hbCount++) {
-                if (unlikely(stream_config[inst_id].initialized == false)) {
+                if (unlikely(!stream_config[inst_id].initialized)) {
                     rxPktsStart[stream_id] += hStat.u.usageData_v0.data.hb[hbCount].stat.rx.frames;
                     rxByteStart[stream_id] += hStat.u.usageData_v0.data.hb[hbCount].stat.rx.bytes;
                     dropPktStart[stream_id] +=
index ec263aeb7859654b209604186d5999ff4d32c9d0..4d0dbcc48af6bcc8f74e08d303e824932175e21c 100644 (file)
@@ -1144,7 +1144,7 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f,
     uint64_t active_id;
     uint64_t log_id = pstate->log_id;
     uint64_t inspect_id = pstate->inspect_id[(direction & STREAM_TOSERVER) ? 0 : 1];
-    if (alp_ctx.ctxs[f->alproto][f->protomap].logger == true) {
+    if (alp_ctx.ctxs[f->alproto][f->protomap].logger) {
         active_id = MIN(log_id, inspect_id);
     } else {
         active_id = inspect_id;
@@ -1525,7 +1525,7 @@ int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
 {
     SCEnter();
     int ipproto_map = FlowGetProtoMapping(ipproto);
-    int r = (alp_ctx.ctxs[alproto][ipproto_map].logger == false) ? 0 : 1;
+    int r = (!alp_ctx.ctxs[alproto][ipproto_map].logger) ? 0 : 1;
     SCReturnInt(r);
 }
 
index 9a845795dded27a61a139bccac46433dda400b0e..97a904eac2a7f19ece16d1fe1015ef7ecc9dde09 100644 (file)
@@ -448,7 +448,7 @@ void StatsSyncCounters(ThreadVars *tv)
 
 void StatsSyncCountersIfSignalled(ThreadVars *tv)
 {
-    if (SC_ATOMIC_GET(tv->perf_public_ctx.sync_now) == true) {
+    if (SC_ATOMIC_GET(tv->perf_public_ctx.sync_now)) {
         StatsUpdateCounterArray(&tv->perf_private_ctx, &tv->perf_public_ctx);
     }
 }
index 7bda136d22a5909dcdbbd13c3de62aa9e3f38f5e..8a384a8e9ee279dc0acc5e78259d3cf9ce6dd1a5 100644 (file)
@@ -82,7 +82,7 @@ static Dataset *DatasetSearchByName(const char *name)
 {
     Dataset *set = sets;
     while (set) {
-        if (strcasecmp(name, set->name) == 0 && set->hidden == false) {
+        if (strcasecmp(name, set->name) == 0 && !set->hidden) {
             return set;
         }
         set = set->next;
@@ -488,7 +488,7 @@ void DatasetReload(void)
     SCMutexLock(&sets_lock);
     Dataset *set = sets;
     while (set) {
-        if (!DatasetIsStatic(set->save, set->load) || set->from_yaml == true) {
+        if (!DatasetIsStatic(set->save, set->load) || set->from_yaml) {
             SCLogDebug("Not a static set, skipping %s", set->name);
             set = set->next;
             continue;
@@ -508,7 +508,7 @@ void DatasetPostReloadCleanup(void)
     Dataset *prev = NULL;
     while (cur) {
         Dataset *next = cur->next;
-        if (cur->hidden == false) {
+        if (!cur->hidden) {
             prev = cur;
             cur = next;
             continue;
index 2ec8e2ad9706434ce3866767981f9dace0e2552f..bdde905b9d8df3be2cf581f37e5d1964acea9d3f 100644 (file)
@@ -87,8 +87,7 @@ int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
 
     p->vlan_id[p->vlan_idx++] = (uint16_t)GET_VLAN_ID(vlan_hdr);
 
-    if (DecodeNetworkLayer(tv, dtv, proto, p,
-                pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN) == false) {
+    if (!DecodeNetworkLayer(tv, dtv, proto, p, pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN)) {
         ENGINE_SET_INVALID_EVENT(p, VLAN_UNKNOWN_TYPE);
         return TM_ECODE_FAILED;
     }
index fdc25fc2a5a92f9d831f414645ac842374cfe178..91ff95f295428fc1749ebe1e1f95497b0d2a1248 100644 (file)
@@ -330,7 +330,7 @@ int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *conten
     DetectContentData *cd = DetectContentParse(de_ctx->spm_global_thread_ctx, contentstr);
     if (cd == NULL)
         goto error;
-    if (s->init_data->negated == true) {
+    if (s->init_data->negated) {
         cd->flags |= DETECT_CONTENT_NEGATED;
     }
 
@@ -824,7 +824,7 @@ static bool TestLastContent(const Signature *s, uint16_t o, uint16_t d)
         FAIL_IF_NULL(s);                                                                           \
         SigPrepareStage1(de_ctx);                                                                  \
         bool res = TestLastContent(s, (o), (d));                                                   \
-        FAIL_IF(res == false);                                                                     \
+        FAIL_IF_NOT(res);                                                                          \
         DetectEngineCtxFree(de_ctx);                                                               \
     }
 
index fd3163d59732fcce709a5cfcd5659464c56cf780..0b46a3522869cf0900f0469f7de5a952fabb66f7 100644 (file)
@@ -187,7 +187,7 @@ static void PrefilterMpmFrame(DetectEngineThreadCtx *det_ctx, const void *pectx,
         fsd.mpm_ctx = mpm_ctx;
 
         if (SetupStreamCallbackData(&fsd, ssn, stream, det_ctx, ctx->transforms, frames, frame,
-                    ctx->list_id, eof) == true) {
+                    ctx->list_id, eof)) {
             StreamReassembleForFrame(ssn, stream, FrameStreamDataPrefilterFunc, &fsd,
                     fsd.requested_stream_offset, eof);
         }
@@ -238,7 +238,7 @@ bool DetectRunFrameInspectRule(ThreadVars *tv, DetectEngineThreadCtx *det_ctx, c
 
             // TODO there should be only one inspect engine for this frame, ever?
 
-            if (e->v1.Callback(det_ctx, e, s, p, frames, frame) == true) {
+            if (e->v1.Callback(det_ctx, e, s, p, frames, frame)) {
                 SCLogDebug("sid %u: e %p Callback returned true", s->id, e);
                 return true;
             }
@@ -591,8 +591,8 @@ int DetectEngineInspectFrameBufferGeneric(DetectEngineThreadCtx *det_ctx,
     fsd.inspect_result = DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
     fsd.p = p;
 
-    if (SetupStreamCallbackData(
-                &fsd, ssn, stream, det_ctx, transforms, frames, frame, list_id, eof) == false) {
+    if (!SetupStreamCallbackData(
+                &fsd, ssn, stream, det_ctx, transforms, frames, frame, list_id, eof)) {
         return DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
     }
     StreamReassembleForFrame(
index 0cb06723810ce958ac2afd1c83d5bbe0fc1f343d..b50d12abd77731a5cd0637a6a606f59f257aa804 100644 (file)
@@ -379,7 +379,7 @@ static DetectGeoipData *DetectGeoipDataParse (DetectEngineCtx *de_ctx, const cha
     /* init geo engine, but not when running as unittests */
     if (!(RunmodeIsUnittests())) {
         /* Initialize the geolocation engine */
-        if (InitGeolocationEngine(geoipdata) == false)
+        if (!InitGeolocationEngine(geoipdata))
             goto error;
     }
 
index 87519bb69bb2ae2d11dc1e3cc9c4775c23285985..9c711d14c2547feaf67a0cfb08a5a5190c4fbd58 100644 (file)
@@ -1049,7 +1049,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr,
 
         /* handle 'silent' error case */
         if (setup_ret == -2) {
-            if (de_ctx->sm_types_silent_error[idx] == false) {
+            if (!de_ctx->sm_types_silent_error[idx]) {
                 de_ctx->sm_types_silent_error[idx] = true;
                 return -1;
             }
@@ -2042,10 +2042,10 @@ static int SigValidate(DetectEngineCtx *de_ctx, Signature *s)
         }
 
         has_frame |= bt->frame;
-        has_app |= (bt->frame == false && bt->packet == false);
+        has_app |= (!bt->frame && !bt->packet);
         has_pkt |= bt->packet;
 
-        if ((s->flags & SIG_FLAG_REQUIRE_PACKET) && bt->packet == false) {
+        if ((s->flags & SIG_FLAG_REQUIRE_PACKET) && !bt->packet) {
             SCLogError("Signature combines packet "
                        "specific matches (like dsize, flags, ttl) with stream / "
                        "state matching by matching on app layer proto (like using "
index 19a569de1a392258f30f6cb5d47d7398a589e214..125b43e893583ae485ce109422ea946bf62901b3 100644 (file)
@@ -595,7 +595,7 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co
 
         /* no flowvars? skip this sig */
         const bool fv = f->flowvar != NULL;
-        if (fv == false) {
+        if (!fv) {
             SCLogDebug("skipping sig as the flow has no flowvars and sig "
                     "has SIG_FLAG_REQUIRE_FLOWVAR flag set.");
             return false;
@@ -824,11 +824,11 @@ static inline void DetectRulePacketRules(
             }
         }
 
-        if (DetectRunInspectRuleHeader(p, pflow, s, sflags, s_proto_flags) == false) {
+        if (!DetectRunInspectRuleHeader(p, pflow, s, sflags, s_proto_flags)) {
             goto next;
         }
 
-        if (DetectEnginePktInspectionRun(tv, det_ctx, s, pflow, p, &alert_flags) == false) {
+        if (!DetectEnginePktInspectionRun(tv, det_ctx, s, pflow, p, &alert_flags)) {
             goto next;
         }
 
@@ -1147,11 +1147,11 @@ static bool DetectRunTxInspectRule(ThreadVars *tv,
     /* for a new inspection we inspect pkt header and packet matches */
     if (likely(stored_flags == NULL)) {
         TRACE_SID_TXS(s->id, tx, "first inspect, run packet matches");
-        if (DetectRunInspectRuleHeader(p, f, s, s->flags, s->proto.flags) == false) {
+        if (!DetectRunInspectRuleHeader(p, f, s, s->flags, s->proto.flags)) {
             TRACE_SID_TXS(s->id, tx, "DetectRunInspectRuleHeader() no match");
             return false;
         }
-        if (DetectEnginePktInspectionRun(tv, det_ctx, s, f, p, NULL) == false) {
+        if (!DetectEnginePktInspectionRun(tv, det_ctx, s, f, p, NULL)) {
             TRACE_SID_TXS(s->id, tx, "DetectEnginePktInspectionRun no match");
             return false;
         }
@@ -1787,9 +1787,9 @@ static void DetectRunFrames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngin
             /* call individual rule inspection */
             RULE_PROFILING_START(p);
             bool r = DetectRunInspectRuleHeader(p, f, s, s->flags, s->proto.flags);
-            if (r == true) {
+            if (r) {
                 r = DetectRunFrameInspectRule(tv, det_ctx, s, f, p, frames, frame);
-                if (r == true) {
+                if (r) {
                     /* match */
                     DetectRunPostMatch(tv, det_ctx, p, s);
 
index 4a3567b75b7e0177c7b85fb3f2b14151eedede7c..4e1efd03c0ec57419efeb12cfa75645b02055fc3 100644 (file)
@@ -356,7 +356,7 @@ static void FlowManagerHashRowTimeout(FlowManagerTimeoutThread *td, Flow *f, SCT
          * be modified when we have both the flow and hash row lock */
 
         /* timeout logic goes here */
-        if (FlowManagerFlowTimeout(f, ts, next_ts, emergency) == false) {
+        if (!FlowManagerFlowTimeout(f, ts, next_ts, emergency)) {
             FLOWLOCK_UNLOCK(f);
             counters->flows_notimeout++;
 
@@ -898,7 +898,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
 
             FlowCountersUpdate(th_v, ftd, &counters);
 
-            if (emerg == true) {
+            if (emerg) {
                 SCLogDebug("flow_sparse_q.len = %" PRIu32 " prealloc: %" PRIu32
                            "flow_spare_q status: %" PRIu32 "%% flows at the queue",
                         spare_pool_len, flow_config.prealloc,
@@ -1162,7 +1162,7 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
                 if (SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY) {
                     break;
                 }
-                if (SC_ATOMIC_GET(flow_recycle_q.non_empty) == true) {
+                if (SC_ATOMIC_GET(flow_recycle_q.non_empty)) {
                     break;
                 }
             }
@@ -1242,7 +1242,7 @@ void FlowDisableFlowRecyclerThread(void)
     do {
         FlowWakeupFlowRecyclerThread();
         usleep(10);
-    } while (FlowRecyclerReadyToShutdown() == false);
+    } while (!FlowRecyclerReadyToShutdown());
 
     SCMutexLock(&tv_root_lock);
     /* flow recycler thread(s) is/are a part of mgmt threads */
index 1d4653b3bf30c5d68db389de3ded4ef20f019718..7d137f2093036a3b0d99e48e448b3cc2326e032d 100644 (file)
@@ -105,13 +105,13 @@ void FlowQueuePrivateAppendPrivate(FlowQueuePrivate *dest, FlowQueuePrivate *src
 
 static inline void FlowQueueAtomicSetNonEmpty(FlowQueue *fq)
 {
-    if (SC_ATOMIC_GET(fq->non_empty) == false) {
+    if (!SC_ATOMIC_GET(fq->non_empty)) {
         SC_ATOMIC_SET(fq->non_empty, true);
     }
 }
 static inline void FlowQueueAtomicSetEmpty(FlowQueue *fq)
 {
-    if (SC_ATOMIC_GET(fq->non_empty) == true) {
+    if (SC_ATOMIC_GET(fq->non_empty)) {
         SC_ATOMIC_SET(fq->non_empty, false);
     }
 }
index 3c95fe8789adfb9b1ade7095ab4b4f424d7e6e45..425b016b09f24cde19b7badc9e552a274a0b9f50 100644 (file)
@@ -470,7 +470,7 @@ static inline void FlowWorkerProcessInjectedFlows(
     /* take injected flows and append to our work queue */
     FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_FLOW_INJECTED);
     FlowQueuePrivate injected = { NULL, NULL, 0 };
-    if (SC_ATOMIC_GET(tv->flow_queue->non_empty) == true)
+    if (SC_ATOMIC_GET(tv->flow_queue->non_empty))
         injected = FlowQueueExtractPrivate(tv->flow_queue);
     if (injected.len > 0) {
         StatsAddUI64(tv, fw->cnt.flows_injected, (uint64_t)injected.len);
index 6df1b1fbafe8e4013913963ce90a9be87f619c73..d9d5a732625a98eeeb0f12daf766880a4ea93786 100644 (file)
@@ -542,7 +542,7 @@ static void *ParseAFPConfig(const char *iface)
         boolval = true;
         if (ConfGetChildValueBoolWithDefault(if_root, if_default, "use-percpu-hash", &boolval) ==
                 1) {
-            if (boolval == false) {
+            if (!boolval) {
                 SCLogConfig("%s: not using percpu hash", aconf->iface);
                 aconf->ebpf_t_config.cpus_count = 1;
             }
index 10213c573879000f3a102a986765d8c599e10281..4df96ce48b7b1b09b2fce64fcffbaf9ba042d970 100644 (file)
@@ -2548,7 +2548,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data)
     if (ptv->flags & (AFP_BYPASS|AFP_XDPBYPASS)) {
         ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4");
         if (ptv->v4_map_fd == -1) {
-            if (g_flowv4_ok == false) {
+            if (!g_flowv4_ok) {
                 SCLogError("Can't find eBPF map fd for '%s'", "flow_table_v4");
                 g_flowv4_ok = true;
             }
index 0f6c9b39bf8add94709a4fd570af21225dc970d3..f178bb39e2ffd9fa44a42e2dbc565a2f8fe689b7 100644 (file)
@@ -284,7 +284,7 @@ TmEcode AFXDPQueueProtectionInit(void)
 
 static TmEcode AFXDPAssignQueueID(AFXDPThreadVars *ptv)
 {
-    if (ptv->xsk.queue.assigned == false) {
+    if (!ptv->xsk.queue.assigned) {
         ptv->xsk.queue.queue_num = SC_ATOMIC_GET(xsk_protect.queue_num);
         SC_ATOMIC_ADD(xsk_protect.queue_num, 1);
 
index cf1c9472a98586e378e6d74b9b16c028cb5986b3..0a7fbe137476fe4fa49e9c3933ccec54062c9b23 100644 (file)
@@ -619,7 +619,7 @@ TmEcode VerdictIPFW(ThreadVars *tv, Packet *p, void *data)
         bool verdict = VerdictTunnelPacket(p);
 
         /* don't verdict if we are not ready */
-        if (verdict == true) {
+        if (verdict) {
             SCLogDebug("Setting verdict on tunnel");
             retval = IPFWSetVerdict(tv, ptv, p->root ? p->root : p);
         }
index 97964af43d823b55eac15262b7eec03a20185113..9e81688e9e8cf36b0afc5ed9163a1ff3b09d76f0 100644 (file)
@@ -1217,7 +1217,7 @@ TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data)
         root_p->nfq_v.verdicted = do_verdict;
         SCSpinUnlock(lock);
         /* don't verdict if we are not ready */
-        if (do_verdict == true) {
+        if (do_verdict) {
             int ret = NFQSetVerdict(root_p, mark_value, mark_modified);
             if (ret != TM_ECODE_OK) {
                 return ret;
index f87c41cda3a43e9d2ca85ab317653b8913fee174..53249e4c4bae051568768164b1ae7142483eaf2a 100644 (file)
@@ -334,7 +334,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
             pv->should_loop = (should_loop == 1);
         }
 
-        if (pv->should_recurse == true && pv->should_loop == true) {
+        if (pv->should_recurse && pv->should_loop) {
             SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
                        "cannot be used together.");
             closedir(directory);
index b4a314663a22e64ddb775c2a9966547274301674..28a3f767093e144a6f931961a15ab935683ab309 100644 (file)
@@ -191,7 +191,7 @@ static int DoInsertSegment (TcpStream *stream, TcpSegment *seg, TcpSegment **dup
             stream->segs_right_edge = SEG_SEQ_RIGHT_EDGE(seg);
 
         /* insert succeeded, now check if we overlap with someone */
-        if (CheckOverlap(&stream->seg_tree, seg) == true) {
+        if (CheckOverlap(&stream->seg_tree, seg)) {
             SCLogDebug("seg %u has overlap in the tree", seg->seq);
             return 1;
         }
index f0e5f3bcf30c5876be5fd51b26b8a6c70f9d878d..47f2b36ecd6ea08ee56cccc453ee92b61ac88443 100644 (file)
@@ -2133,7 +2133,7 @@ static int StreamTcpPacketStateSynSent(
     }
 
     /* check for bad responses */
-    if (StateSynSentValidateTimestamp(ssn, p) == false) {
+    if (!StateSynSentValidateTimestamp(ssn, p)) {
         StreamTcpSetEvent(p, STREAM_PKT_INVALID_TIMESTAMP);
         return -1;
     }
@@ -5625,7 +5625,7 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
             goto skip;
         }
 
-        if (StreamTcpPacketIsDupAck(ssn, p) == true) {
+        if (StreamTcpPacketIsDupAck(ssn, p)) {
             STREAM_PKT_FLAG_SET(p, STREAM_PKT_FLAG_DUP_ACK);
             // TODO see if we can skip work on these
         }
index dddc702b2589f7a3ddf6d0aefbb51735a5be0701..2c9fbe04dd76a78ebc274af7e707117f9843fed8 100644 (file)
@@ -2600,14 +2600,14 @@ static void PostConfLoadedSetupHostMode(void)
 static void SetupUserMode(SCInstance *suri)
 {
     /* apply 'user mode' config updates here */
-    if (suri->system == false) {
-        if (suri->set_logdir == false) {
+    if (!suri->system) {
+        if (!suri->set_logdir) {
             /* override log dir to current work dir" */
             if (ConfigSetLogDirectory((char *)".") != TM_ECODE_OK) {
                 FatalError("could not set USER mode logdir");
             }
         }
-        if (suri->set_datadir == false) {
+        if (!suri->set_datadir) {
             /* override data dir to current work dir" */
             if (ConfigSetDataDirectory((char *)".") != TM_ECODE_OK) {
                 FatalError("could not set USER mode datadir");
index e184ec9827db39326f92b7f67a5ed678ccd65de3..81bbc3042b83b5637c55b4bee639a579c94d57d1 100644 (file)
@@ -116,7 +116,7 @@ void TmValidateQueueState(void)
         }
         SCMutexUnlock(&tmq->pq->mutex_q);
 
-        if (err == true)
+        if (err)
             goto error;
     }
 
index b8ba6cde04e958831037e4b6452004c0eb69e543..1638aa5d4db97fef9d217aa8ea56bfe7b11b9a8e 100644 (file)
@@ -464,7 +464,7 @@ static void *TmThreadsSlotVar(void *td)
 
         /* if we didn't get a packet see if we need to do some housekeeping */
         if (unlikely(p == NULL)) {
-            if (tv->flow_queue && SC_ATOMIC_GET(tv->flow_queue->non_empty) == true) {
+            if (tv->flow_queue && SC_ATOMIC_GET(tv->flow_queue->non_empty)) {
                 p = PacketGetFromQueueOrAlloc();
                 if (p != NULL) {
                     p->flags |= PKT_PSEUDO_STREAM_END;
index dde0f2029ee9e2a9e8c1cda00bedc2bf369f1c9b..9c644a31be29c4836a494497a216795ad78f6717 100644 (file)
@@ -243,9 +243,9 @@ static inline void TmThreadsCaptureHandleTimeout(ThreadVars *tv, Packet *p)
         return;
 
     } else {
-        if (TmThreadsHandleInjectedPackets(tv) == false) {
+        if (!TmThreadsHandleInjectedPackets(tv)) {
             /* see if we have to do some house keeping */
-            if (tv->flow_queue && SC_ATOMIC_GET(tv->flow_queue->non_empty) == true) {
+            if (tv->flow_queue && SC_ATOMIC_GET(tv->flow_queue->non_empty)) {
                 TmThreadsCaptureInjectPacket(tv, p); /* consumes 'p' */
                 return;
             }
index 39ea3eff6cd70bc876abecf105e2bc0213fe6f64..e301025730b8cd55336dc5451f06ea6b7ffcb0d9 100644 (file)
@@ -398,7 +398,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
             (p->action & ACTION_DROP) ? "DROP" : "no drop");
 
     /* we're done with the tunnel root now as well */
-    if (proot == true) {
+    if (proot) {
         SCLogDebug("getting rid of root pkt... alloc'd %s", BOOL2STR(p->root->pool == NULL));
 
         PacketReleaseRefs(p->root);
index ea0811b89a1528ec4c120790d4d23099815331ea..6b00fe2b4c9727aaca9bb0c89d00d50c4720c74c 100644 (file)
@@ -380,7 +380,7 @@ int EBPFLoadFile(const char *iface, const char *path, const char * section,
         }
     }
 
-    if (found == false) {
+    if (!found) {
         SCLogError("No section '%s' in '%s' file. Will not be able to use the file", section, path);
         return -1;
     }
index 8251b42aa544ed979f3b50c2b3f1bacb2bc300be..20322419194c114715973f4a6c391d11b8221d8a 100644 (file)
@@ -377,7 +377,7 @@ static RADIX_NODE_TYPE *AddKey(RADIX_TREE_TYPE *tree, const RADIX_CONFIG_TYPE *c
      * being the incoming prefix is shorter than the differ bit of the current
      * node.  In case we fail in this aspect, we walk down to the tree, till we
      * arrive at a node that ends in a prefix */
-    while (node->bit < NETMASK_MAX || node->has_prefix == false) {
+    while (node->bit < NETMASK_MAX || !node->has_prefix) {
         /* if the bitlen isn't long enough to handle the bit test, we just walk
          * down along one of the paths, since either paths should end up with a
          * node that has a common prefix whose differ bit is greater than the
@@ -614,7 +614,7 @@ static void RemoveKey(RADIX_TREE_TYPE *tree, const RADIX_CONFIG_TYPE *config,
         }
     }
 
-    if (node->bit != NETMASK_MAX || node->has_prefix == false) {
+    if (node->bit != NETMASK_MAX || !node->has_prefix) {
         SCLogDebug("node %p bit %d != %d, or not has_prefix %s", node, node->bit, NETMASK_MAX,
                 node->has_prefix ? "true" : "false");
         return;
@@ -751,7 +751,7 @@ static inline RADIX_NODE_TYPE *FindKeyIPNetblock(const uint8_t *key_stream, RADI
                 return NULL;
         }
 
-        if (node->bit != NETMASK_MAX || node->has_prefix == false)
+        if (node->bit != NETMASK_MAX || !node->has_prefix)
             return NULL;
 
         if (SCMemcmp(node->prefix_stream, tmp_stream, sizeof(tmp_stream)) == 0) {
@@ -795,7 +795,7 @@ static RADIX_NODE_TYPE *FindKey(const RADIX_TREE_TYPE *tree, const uint8_t *key_
         }
     }
 
-    if (node->bit != NETMASK_MAX || node->has_prefix == false) {
+    if (node->bit != NETMASK_MAX || !node->has_prefix) {
         return NULL;
     }
 
@@ -937,7 +937,7 @@ static bool CompareTreesSub(
             return false;
 
         if (Callback != NULL) {
-            if (Callback(u1->user, u2->user) == false)
+            if (!Callback(u1->user, u2->user))
                 return false;
         }
 
@@ -946,10 +946,10 @@ static bool CompareTreesSub(
     }
 
     if (n1->left && n2->left)
-        if (CompareTreesSub(n1->left, n2->left, Callback) == false)
+        if (!CompareTreesSub(n1->left, n2->left, Callback))
             return false;
     if (n1->right && n2->right)
-        if (CompareTreesSub(n1->right, n2->right, Callback) == false)
+        if (!CompareTreesSub(n1->right, n2->right, Callback))
             return false;
 
     return true;
index 9ae3039087c8191f56c89002e812289108880ee4..2221941bda008a99eed59c3666775bed3559131c 100644 (file)
@@ -159,7 +159,7 @@ static StreamingBufferRegion *FindFirstRegionForOffset(const StreamingBufferConf
 
     StreamingBufferRegion *p = NULL;
     for (; r != NULL; r = r->next) {
-        if (RegionsIntersect(cfg, r, offset, data_re) == true) {
+        if (RegionsIntersect(cfg, r, offset, data_re)) {
             *prev = p;
             return r;
         }
index be6e930bcc5f60454ceb171c7468fa31bfe58b2d..4c18c402a4ce07bd93837efd84d1025aa61741f0 100644 (file)
@@ -417,7 +417,7 @@ int THashWalk(THashTableContext *ctx, THashFormatFunc FormatterFunc, THashOutput
             h = h->next;
         }
         HRLOCK_UNLOCK(hb);
-        if (err == true)
+        if (err)
             return -1;
     }
     return 0;