gen/bool: Clarify bool checks

Remove comparisons with true or false with C bools.
pull/12625/head
Jeff Lucovsky 2 weeks ago committed by Victor Julien
parent b514b25165
commit 7d5c170dd2

@ -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; for (uint32_t hbCount = 0; hbCount < hStat.u.usageData_v0.data.numHostBufferUsed;
hbCount++) { 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; 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; rxByteStart[stream_id] += hStat.u.usageData_v0.data.hb[hbCount].stat.rx.bytes;
dropPktStart[stream_id] += dropPktStart[stream_id] +=

@ -1144,7 +1144,7 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f,
uint64_t active_id; uint64_t active_id;
uint64_t log_id = pstate->log_id; uint64_t log_id = pstate->log_id;
uint64_t inspect_id = pstate->inspect_id[(direction & STREAM_TOSERVER) ? 0 : 1]; 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); active_id = MIN(log_id, inspect_id);
} else { } else {
active_id = inspect_id; active_id = inspect_id;
@ -1525,7 +1525,7 @@ int AppLayerParserProtocolHasLogger(uint8_t ipproto, AppProto alproto)
{ {
SCEnter(); SCEnter();
int ipproto_map = FlowGetProtoMapping(ipproto); 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); SCReturnInt(r);
} }

@ -448,7 +448,7 @@ void StatsSyncCounters(ThreadVars *tv)
void StatsSyncCountersIfSignalled(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); StatsUpdateCounterArray(&tv->perf_private_ctx, &tv->perf_public_ctx);
} }
} }

@ -82,7 +82,7 @@ static Dataset *DatasetSearchByName(const char *name)
{ {
Dataset *set = sets; Dataset *set = sets;
while (set) { while (set) {
if (strcasecmp(name, set->name) == 0 && set->hidden == false) { if (strcasecmp(name, set->name) == 0 && !set->hidden) {
return set; return set;
} }
set = set->next; set = set->next;
@ -488,7 +488,7 @@ void DatasetReload(void)
SCMutexLock(&sets_lock); SCMutexLock(&sets_lock);
Dataset *set = sets; Dataset *set = sets;
while (set) { 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); SCLogDebug("Not a static set, skipping %s", set->name);
set = set->next; set = set->next;
continue; continue;
@ -508,7 +508,7 @@ void DatasetPostReloadCleanup(void)
Dataset *prev = NULL; Dataset *prev = NULL;
while (cur) { while (cur) {
Dataset *next = cur->next; Dataset *next = cur->next;
if (cur->hidden == false) { if (!cur->hidden) {
prev = cur; prev = cur;
cur = next; cur = next;
continue; continue;

@ -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); p->vlan_id[p->vlan_idx++] = (uint16_t)GET_VLAN_ID(vlan_hdr);
if (DecodeNetworkLayer(tv, dtv, proto, p, if (!DecodeNetworkLayer(tv, dtv, proto, p, pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN)) {
pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN) == false) {
ENGINE_SET_INVALID_EVENT(p, VLAN_UNKNOWN_TYPE); ENGINE_SET_INVALID_EVENT(p, VLAN_UNKNOWN_TYPE);
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }

@ -330,7 +330,7 @@ int DetectContentSetup(DetectEngineCtx *de_ctx, Signature *s, const char *conten
DetectContentData *cd = DetectContentParse(de_ctx->spm_global_thread_ctx, contentstr); DetectContentData *cd = DetectContentParse(de_ctx->spm_global_thread_ctx, contentstr);
if (cd == NULL) if (cd == NULL)
goto error; goto error;
if (s->init_data->negated == true) { if (s->init_data->negated) {
cd->flags |= DETECT_CONTENT_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); \ FAIL_IF_NULL(s); \
SigPrepareStage1(de_ctx); \ SigPrepareStage1(de_ctx); \
bool res = TestLastContent(s, (o), (d)); \ bool res = TestLastContent(s, (o), (d)); \
FAIL_IF(res == false); \ FAIL_IF_NOT(res); \
DetectEngineCtxFree(de_ctx); \ DetectEngineCtxFree(de_ctx); \
} }

@ -187,7 +187,7 @@ static void PrefilterMpmFrame(DetectEngineThreadCtx *det_ctx, const void *pectx,
fsd.mpm_ctx = mpm_ctx; fsd.mpm_ctx = mpm_ctx;
if (SetupStreamCallbackData(&fsd, ssn, stream, det_ctx, ctx->transforms, frames, frame, 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, StreamReassembleForFrame(ssn, stream, FrameStreamDataPrefilterFunc, &fsd,
fsd.requested_stream_offset, eof); 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? // 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); SCLogDebug("sid %u: e %p Callback returned true", s->id, e);
return true; return true;
} }
@ -591,8 +591,8 @@ int DetectEngineInspectFrameBufferGeneric(DetectEngineThreadCtx *det_ctx,
fsd.inspect_result = DETECT_ENGINE_INSPECT_SIG_NO_MATCH; fsd.inspect_result = DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
fsd.p = p; fsd.p = p;
if (SetupStreamCallbackData( if (!SetupStreamCallbackData(
&fsd, ssn, stream, det_ctx, transforms, frames, frame, list_id, eof) == false) { &fsd, ssn, stream, det_ctx, transforms, frames, frame, list_id, eof)) {
return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; return DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
} }
StreamReassembleForFrame( StreamReassembleForFrame(

@ -379,7 +379,7 @@ static DetectGeoipData *DetectGeoipDataParse (DetectEngineCtx *de_ctx, const cha
/* init geo engine, but not when running as unittests */ /* init geo engine, but not when running as unittests */
if (!(RunmodeIsUnittests())) { if (!(RunmodeIsUnittests())) {
/* Initialize the geolocation engine */ /* Initialize the geolocation engine */
if (InitGeolocationEngine(geoipdata) == false) if (!InitGeolocationEngine(geoipdata))
goto error; goto error;
} }

@ -1049,7 +1049,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr,
/* handle 'silent' error case */ /* handle 'silent' error case */
if (setup_ret == -2) { 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; de_ctx->sm_types_silent_error[idx] = true;
return -1; return -1;
} }
@ -2042,10 +2042,10 @@ static int SigValidate(DetectEngineCtx *de_ctx, Signature *s)
} }
has_frame |= bt->frame; has_frame |= bt->frame;
has_app |= (bt->frame == false && bt->packet == false); has_app |= (!bt->frame && !bt->packet);
has_pkt |= 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 " SCLogError("Signature combines packet "
"specific matches (like dsize, flags, ttl) with stream / " "specific matches (like dsize, flags, ttl) with stream / "
"state matching by matching on app layer proto (like using " "state matching by matching on app layer proto (like using "

@ -595,7 +595,7 @@ static inline bool DetectRunInspectRuleHeader(const Packet *p, const Flow *f, co
/* no flowvars? skip this sig */ /* no flowvars? skip this sig */
const bool fv = f->flowvar != NULL; const bool fv = f->flowvar != NULL;
if (fv == false) { if (!fv) {
SCLogDebug("skipping sig as the flow has no flowvars and sig " SCLogDebug("skipping sig as the flow has no flowvars and sig "
"has SIG_FLAG_REQUIRE_FLOWVAR flag set."); "has SIG_FLAG_REQUIRE_FLOWVAR flag set.");
return false; 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; 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; goto next;
} }
@ -1147,11 +1147,11 @@ static bool DetectRunTxInspectRule(ThreadVars *tv,
/* for a new inspection we inspect pkt header and packet matches */ /* for a new inspection we inspect pkt header and packet matches */
if (likely(stored_flags == NULL)) { if (likely(stored_flags == NULL)) {
TRACE_SID_TXS(s->id, tx, "first inspect, run packet matches"); 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"); TRACE_SID_TXS(s->id, tx, "DetectRunInspectRuleHeader() no match");
return false; 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"); TRACE_SID_TXS(s->id, tx, "DetectEnginePktInspectionRun no match");
return false; return false;
} }
@ -1787,9 +1787,9 @@ static void DetectRunFrames(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngin
/* call individual rule inspection */ /* call individual rule inspection */
RULE_PROFILING_START(p); RULE_PROFILING_START(p);
bool r = DetectRunInspectRuleHeader(p, f, s, s->flags, s->proto.flags); 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); r = DetectRunFrameInspectRule(tv, det_ctx, s, f, p, frames, frame);
if (r == true) { if (r) {
/* match */ /* match */
DetectRunPostMatch(tv, det_ctx, p, s); DetectRunPostMatch(tv, det_ctx, p, s);

@ -356,7 +356,7 @@ static void FlowManagerHashRowTimeout(FlowManagerTimeoutThread *td, Flow *f, SCT
* be modified when we have both the flow and hash row lock */ * be modified when we have both the flow and hash row lock */
/* timeout logic goes here */ /* timeout logic goes here */
if (FlowManagerFlowTimeout(f, ts, next_ts, emergency) == false) { if (!FlowManagerFlowTimeout(f, ts, next_ts, emergency)) {
FLOWLOCK_UNLOCK(f); FLOWLOCK_UNLOCK(f);
counters->flows_notimeout++; counters->flows_notimeout++;
@ -898,7 +898,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
FlowCountersUpdate(th_v, ftd, &counters); FlowCountersUpdate(th_v, ftd, &counters);
if (emerg == true) { if (emerg) {
SCLogDebug("flow_sparse_q.len = %" PRIu32 " prealloc: %" PRIu32 SCLogDebug("flow_sparse_q.len = %" PRIu32 " prealloc: %" PRIu32
"flow_spare_q status: %" PRIu32 "%% flows at the queue", "flow_spare_q status: %" PRIu32 "%% flows at the queue",
spare_pool_len, flow_config.prealloc, 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) { if (SC_ATOMIC_GET(flow_flags) & FLOW_EMERGENCY) {
break; break;
} }
if (SC_ATOMIC_GET(flow_recycle_q.non_empty) == true) { if (SC_ATOMIC_GET(flow_recycle_q.non_empty)) {
break; break;
} }
} }
@ -1242,7 +1242,7 @@ void FlowDisableFlowRecyclerThread(void)
do { do {
FlowWakeupFlowRecyclerThread(); FlowWakeupFlowRecyclerThread();
usleep(10); usleep(10);
} while (FlowRecyclerReadyToShutdown() == false); } while (!FlowRecyclerReadyToShutdown());
SCMutexLock(&tv_root_lock); SCMutexLock(&tv_root_lock);
/* flow recycler thread(s) is/are a part of mgmt threads */ /* flow recycler thread(s) is/are a part of mgmt threads */

@ -105,13 +105,13 @@ void FlowQueuePrivateAppendPrivate(FlowQueuePrivate *dest, FlowQueuePrivate *src
static inline void FlowQueueAtomicSetNonEmpty(FlowQueue *fq) 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); SC_ATOMIC_SET(fq->non_empty, true);
} }
} }
static inline void FlowQueueAtomicSetEmpty(FlowQueue *fq) 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); SC_ATOMIC_SET(fq->non_empty, false);
} }
} }

@ -470,7 +470,7 @@ static inline void FlowWorkerProcessInjectedFlows(
/* take injected flows and append to our work queue */ /* take injected flows and append to our work queue */
FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_FLOW_INJECTED); FLOWWORKER_PROFILING_START(p, PROFILE_FLOWWORKER_FLOW_INJECTED);
FlowQueuePrivate injected = { NULL, NULL, 0 }; 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); injected = FlowQueueExtractPrivate(tv->flow_queue);
if (injected.len > 0) { if (injected.len > 0) {
StatsAddUI64(tv, fw->cnt.flows_injected, (uint64_t)injected.len); StatsAddUI64(tv, fw->cnt.flows_injected, (uint64_t)injected.len);

@ -542,7 +542,7 @@ static void *ParseAFPConfig(const char *iface)
boolval = true; boolval = true;
if (ConfGetChildValueBoolWithDefault(if_root, if_default, "use-percpu-hash", &boolval) == if (ConfGetChildValueBoolWithDefault(if_root, if_default, "use-percpu-hash", &boolval) ==
1) { 1) {
if (boolval == false) { if (!boolval) {
SCLogConfig("%s: not using percpu hash", aconf->iface); SCLogConfig("%s: not using percpu hash", aconf->iface);
aconf->ebpf_t_config.cpus_count = 1; aconf->ebpf_t_config.cpus_count = 1;
} }

@ -2548,7 +2548,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data)
if (ptv->flags & (AFP_BYPASS|AFP_XDPBYPASS)) { if (ptv->flags & (AFP_BYPASS|AFP_XDPBYPASS)) {
ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4"); ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4");
if (ptv->v4_map_fd == -1) { 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"); SCLogError("Can't find eBPF map fd for '%s'", "flow_table_v4");
g_flowv4_ok = true; g_flowv4_ok = true;
} }

@ -284,7 +284,7 @@ TmEcode AFXDPQueueProtectionInit(void)
static TmEcode AFXDPAssignQueueID(AFXDPThreadVars *ptv) 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); ptv->xsk.queue.queue_num = SC_ATOMIC_GET(xsk_protect.queue_num);
SC_ATOMIC_ADD(xsk_protect.queue_num, 1); SC_ATOMIC_ADD(xsk_protect.queue_num, 1);

@ -619,7 +619,7 @@ TmEcode VerdictIPFW(ThreadVars *tv, Packet *p, void *data)
bool verdict = VerdictTunnelPacket(p); bool verdict = VerdictTunnelPacket(p);
/* don't verdict if we are not ready */ /* don't verdict if we are not ready */
if (verdict == true) { if (verdict) {
SCLogDebug("Setting verdict on tunnel"); SCLogDebug("Setting verdict on tunnel");
retval = IPFWSetVerdict(tv, ptv, p->root ? p->root : p); retval = IPFWSetVerdict(tv, ptv, p->root ? p->root : p);
} }

@ -1217,7 +1217,7 @@ TmEcode VerdictNFQ(ThreadVars *tv, Packet *p, void *data)
root_p->nfq_v.verdicted = do_verdict; root_p->nfq_v.verdicted = do_verdict;
SCSpinUnlock(lock); SCSpinUnlock(lock);
/* don't verdict if we are not ready */ /* don't verdict if we are not ready */
if (do_verdict == true) { if (do_verdict) {
int ret = NFQSetVerdict(root_p, mark_value, mark_modified); int ret = NFQSetVerdict(root_p, mark_value, mark_modified);
if (ret != TM_ECODE_OK) { if (ret != TM_ECODE_OK) {
return ret; return ret;

@ -334,7 +334,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, const void *initdata, void **d
pv->should_loop = (should_loop == 1); 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 " SCLogError("Error, --pcap-file-continuous and --pcap-file-recursive "
"cannot be used together."); "cannot be used together.");
closedir(directory); closedir(directory);

@ -191,7 +191,7 @@ static int DoInsertSegment (TcpStream *stream, TcpSegment *seg, TcpSegment **dup
stream->segs_right_edge = SEG_SEQ_RIGHT_EDGE(seg); stream->segs_right_edge = SEG_SEQ_RIGHT_EDGE(seg);
/* insert succeeded, now check if we overlap with someone */ /* 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); SCLogDebug("seg %u has overlap in the tree", seg->seq);
return 1; return 1;
} }

@ -2133,7 +2133,7 @@ static int StreamTcpPacketStateSynSent(
} }
/* check for bad responses */ /* check for bad responses */
if (StateSynSentValidateTimestamp(ssn, p) == false) { if (!StateSynSentValidateTimestamp(ssn, p)) {
StreamTcpSetEvent(p, STREAM_PKT_INVALID_TIMESTAMP); StreamTcpSetEvent(p, STREAM_PKT_INVALID_TIMESTAMP);
return -1; return -1;
} }
@ -5625,7 +5625,7 @@ int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
goto skip; goto skip;
} }
if (StreamTcpPacketIsDupAck(ssn, p) == true) { if (StreamTcpPacketIsDupAck(ssn, p)) {
STREAM_PKT_FLAG_SET(p, STREAM_PKT_FLAG_DUP_ACK); STREAM_PKT_FLAG_SET(p, STREAM_PKT_FLAG_DUP_ACK);
// TODO see if we can skip work on these // TODO see if we can skip work on these
} }

@ -2600,14 +2600,14 @@ static void PostConfLoadedSetupHostMode(void)
static void SetupUserMode(SCInstance *suri) static void SetupUserMode(SCInstance *suri)
{ {
/* apply 'user mode' config updates here */ /* apply 'user mode' config updates here */
if (suri->system == false) { if (!suri->system) {
if (suri->set_logdir == false) { if (!suri->set_logdir) {
/* override log dir to current work dir" */ /* override log dir to current work dir" */
if (ConfigSetLogDirectory((char *)".") != TM_ECODE_OK) { if (ConfigSetLogDirectory((char *)".") != TM_ECODE_OK) {
FatalError("could not set USER mode logdir"); FatalError("could not set USER mode logdir");
} }
} }
if (suri->set_datadir == false) { if (!suri->set_datadir) {
/* override data dir to current work dir" */ /* override data dir to current work dir" */
if (ConfigSetDataDirectory((char *)".") != TM_ECODE_OK) { if (ConfigSetDataDirectory((char *)".") != TM_ECODE_OK) {
FatalError("could not set USER mode datadir"); FatalError("could not set USER mode datadir");

@ -116,7 +116,7 @@ void TmValidateQueueState(void)
} }
SCMutexUnlock(&tmq->pq->mutex_q); SCMutexUnlock(&tmq->pq->mutex_q);
if (err == true) if (err)
goto error; goto error;
} }

@ -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 we didn't get a packet see if we need to do some housekeeping */
if (unlikely(p == NULL)) { 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(); p = PacketGetFromQueueOrAlloc();
if (p != NULL) { if (p != NULL) {
p->flags |= PKT_PSEUDO_STREAM_END; p->flags |= PKT_PSEUDO_STREAM_END;

@ -243,9 +243,9 @@ static inline void TmThreadsCaptureHandleTimeout(ThreadVars *tv, Packet *p)
return; return;
} else { } else {
if (TmThreadsHandleInjectedPackets(tv) == false) { if (!TmThreadsHandleInjectedPackets(tv)) {
/* see if we have to do some house keeping */ /* 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' */ TmThreadsCaptureInjectPacket(tv, p); /* consumes 'p' */
return; return;
} }

@ -398,7 +398,7 @@ void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
(p->action & ACTION_DROP) ? "DROP" : "no drop"); (p->action & ACTION_DROP) ? "DROP" : "no drop");
/* we're done with the tunnel root now as well */ /* 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)); SCLogDebug("getting rid of root pkt... alloc'd %s", BOOL2STR(p->root->pool == NULL));
PacketReleaseRefs(p->root); PacketReleaseRefs(p->root);

@ -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); SCLogError("No section '%s' in '%s' file. Will not be able to use the file", section, path);
return -1; return -1;
} }

@ -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 * 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 * 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 */ * 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 /* 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 * 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 * 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, SCLogDebug("node %p bit %d != %d, or not has_prefix %s", node, node->bit, NETMASK_MAX,
node->has_prefix ? "true" : "false"); node->has_prefix ? "true" : "false");
return; return;
@ -751,7 +751,7 @@ static inline RADIX_NODE_TYPE *FindKeyIPNetblock(const uint8_t *key_stream, RADI
return NULL; return NULL;
} }
if (node->bit != NETMASK_MAX || node->has_prefix == false) if (node->bit != NETMASK_MAX || !node->has_prefix)
return NULL; return NULL;
if (SCMemcmp(node->prefix_stream, tmp_stream, sizeof(tmp_stream)) == 0) { 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; return NULL;
} }
@ -937,7 +937,7 @@ static bool CompareTreesSub(
return false; return false;
if (Callback != NULL) { if (Callback != NULL) {
if (Callback(u1->user, u2->user) == false) if (!Callback(u1->user, u2->user))
return false; return false;
} }
@ -946,10 +946,10 @@ static bool CompareTreesSub(
} }
if (n1->left && n2->left) if (n1->left && n2->left)
if (CompareTreesSub(n1->left, n2->left, Callback) == false) if (!CompareTreesSub(n1->left, n2->left, Callback))
return false; return false;
if (n1->right && n2->right) if (n1->right && n2->right)
if (CompareTreesSub(n1->right, n2->right, Callback) == false) if (!CompareTreesSub(n1->right, n2->right, Callback))
return false; return false;
return true; return true;

@ -159,7 +159,7 @@ static StreamingBufferRegion *FindFirstRegionForOffset(const StreamingBufferConf
StreamingBufferRegion *p = NULL; StreamingBufferRegion *p = NULL;
for (; r != NULL; r = r->next) { for (; r != NULL; r = r->next) {
if (RegionsIntersect(cfg, r, offset, data_re) == true) { if (RegionsIntersect(cfg, r, offset, data_re)) {
*prev = p; *prev = p;
return r; return r;
} }

@ -417,7 +417,7 @@ int THashWalk(THashTableContext *ctx, THashFormatFunc FormatterFunc, THashOutput
h = h->next; h = h->next;
} }
HRLOCK_UNLOCK(hb); HRLOCK_UNLOCK(hb);
if (err == true) if (err)
return -1; return -1;
} }
return 0; return 0;

Loading…
Cancel
Save