misc/cleanup: Simplify <cond> ? true : false

Simplify statements where there's a conditional statement followed by
return true or return false.

Instead of
    if (conditional)
        return true;
    else
        return false;

Use:
        return conditional
pull/15080/head
Jeff Lucovsky 4 months ago committed by Victor Julien
parent 468a13e052
commit 022a79fdd5

@ -119,10 +119,7 @@ static bool ContainerUrlRangeCompare(void *a, void *b)
return false;
}
if (SCBufferCmp(as->key, as->len, bs->key, bs->len) == 0) {
return true;
}
return false;
return SCBufferCmp(as->key, as->len, bs->key, bs->len) == 0;
}
static uint32_t ContainerUrlRangeHash(uint32_t hash_seed, void *s)

@ -807,10 +807,7 @@ void SCConfDump(void)
*/
bool SCConfNodeHasChildren(const SCConfNode *node)
{
if (TAILQ_EMPTY(&node->head)) {
return false;
}
return true;
return !TAILQ_EMPTY(&node->head);
}
/**

@ -72,10 +72,7 @@ static bool IsFloat(const char *in, size_t ins)
return true;
}
/* if value is 0 then we need to check if some parsing has been done */
if (val == 0 && (endptr == in)) {
return false;
}
return true;
return val != 0 || endptr != in;
}
static int ParseJsonLine(const char *in, size_t ins, DataJsonType *rep_out)

@ -533,11 +533,7 @@ static bool DatasetIsStatic(const char *save, const char *load)
/* A set is static if it does not have any dynamic properties like
* save and/or state defined but has load defined.
* */
if ((load != NULL && strlen(load) > 0) &&
(save == NULL || strlen(save) == 0)) {
return true;
}
return false;
return (load != NULL && strlen(load) > 0) && (save == NULL || strlen(save) == 0);
}
void DatasetReload(void)

@ -99,7 +99,7 @@ void DecodeIPV6FragHeader(Packet *p, const uint8_t *pkt,
int frag_morefrags = (*(pkt + 2) << 8 | *(pkt + 3)) & 0x0001;
p->l3.vars.ip6.eh.fh_offset = frag_offset;
p->l3.vars.ip6.eh.fh_more_frags_set = frag_morefrags ? true : false;
p->l3.vars.ip6.eh.fh_more_frags_set = frag_morefrags;
p->l3.vars.ip6.eh.fh_nh = *pkt;
uint32_t fh_id;

@ -165,12 +165,9 @@ static DetectAppLayerEventData *DetectAppLayerEventParsePkt(const char *arg,
static bool OutdatedEvent(const char *raw)
{
if (strcmp(raw, "tls.certificate_missing_element") == 0 ||
return strcmp(raw, "tls.certificate_missing_element") == 0 ||
strcmp(raw, "tls.certificate_unknown_element") == 0 ||
strcmp(raw, "tls.certificate_invalid_string") == 0) {
return true;
}
return false;
strcmp(raw, "tls.certificate_invalid_string") == 0;
}
static AppProto AppLayerEventGetProtoByName(char *alproto_name)

@ -373,9 +373,7 @@ static bool
PrefilterPacketAppProtoCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectAppLayerProtocolData *a = smctx;
if (v.u16[0] == a->alproto && v.u8[2] == (uint8_t)a->negated && v.u8[3] == a->mode)
return true;
return false;
return v.u16[0] == a->alproto && v.u8[2] == (uint8_t)a->negated && v.u8[3] == a->mode;
}
static int PrefilterSetupAppProto(DetectEngineCtx *de_ctx, SigGroupHead *sgh)

@ -194,10 +194,7 @@ static bool GetMimeEmailUrlData(DetectEngineThreadCtx *det_ctx, const void *txv,
return false;
}
if (SCDetectMimeEmailGetUrl(tx->mime_state, buf, buf_len, idx) != 1) {
return false;
}
return true;
return SCDetectMimeEmailGetUrl(tx->mime_state, buf, buf_len, idx) == 1;
}
static int DetectMimeEmailReceivedSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
@ -220,10 +217,7 @@ static bool GetMimeEmailReceivedData(DetectEngineThreadCtx *det_ctx, const void
return false;
}
if (SCDetectMimeEmailGetDataArray(tx->mime_state, buf, buf_len, "received", idx) != 1) {
return false;
}
return true;
return SCDetectMimeEmailGetDataArray(tx->mime_state, buf, buf_len, "received", idx) == 1;
}
int DETECT_EMAIL_BODY_MD5 = 0;

@ -361,11 +361,7 @@ bool DetectAddressListsAreEqual(DetectAddress *list1, DetectAddress *list2)
}
// Are the lists of the same size?
if (!(item == NULL && it == NULL)) {
return false;
}
return true;
return item == NULL && it == NULL;
}
/**

@ -569,9 +569,7 @@ static void SigInitStandardMpmFactoryContexts(DetectEngineCtx *de_ctx)
/** \brief Pure-PCRE or bytetest rule */
static bool RuleInspectsPayloadHasNoMpm(const Signature *s)
{
if (s->init_data->mpm_sm == NULL && s->init_data->smlists[DETECT_SM_LIST_PMATCH] != NULL)
return true;
return false;
return s->init_data->mpm_sm == NULL && s->init_data->smlists[DETECT_SM_LIST_PMATCH] != NULL;
}
static int RuleGetMpmPatternSize(const Signature *s)
@ -599,7 +597,7 @@ static bool RuleMpmIsNegated(const Signature *s)
const DetectContentData *cd = (const DetectContentData *)s->init_data->mpm_sm->ctx;
if (cd == NULL)
return false;
return (cd->flags & DETECT_CONTENT_NEGATED) ? true : false;
return (cd->flags & DETECT_CONTENT_NEGATED) != 0;
}
static SCJsonBuilder *RulesGroupPrintSghStats(const DetectEngineCtx *de_ctx,

@ -762,10 +762,7 @@ bool DetectEngineContentInspection(DetectEngineCtx *de_ctx, DetectEngineThreadCt
#ifdef UNITTESTS
ut_inspection_recursion_counter = ctx.recursion.count;
#endif
if (r == 1)
return true;
else
return false;
return (r == 1);
}
/** \brief wrapper around DetectEngineContentInspectionInternal to return true/false only
@ -786,10 +783,7 @@ bool DetectEngineContentInspectionBuffer(DetectEngineCtx *de_ctx, DetectEngineTh
#ifdef UNITTESTS
ut_inspection_recursion_counter = ctx.recursion.count;
#endif
if (r == 1)
return true;
else
return false;
return (r == 1);
}
bool DetectContentInspectionMatchOnAbsentBuffer(const SigMatchData *smd)

@ -186,10 +186,7 @@ static int DetectEngineEventMatch (DetectEngineThreadCtx *det_ctx,
static bool OutdatedEvent(const char *raw)
{
if (strcmp(raw, "decoder.udp.hlen_invalid") == 0) {
return true;
}
return false;
return strcmp(raw, "decoder.udp.hlen_invalid") == 0;
}
/**

@ -623,11 +623,7 @@ bool DetectPortListsAreEqual(DetectPort *list1, DetectPort *list2)
}
// Are the lists of the same size?
if (!(item == NULL && it == NULL)) {
return false;
}
return true;
return item == NULL && it == NULL;
}
/******************* parsing routines ************************/
@ -1249,10 +1245,7 @@ error:
*/
static bool DetectPortIsValidRange(char *port, uint16_t *port_val)
{
if (StringParseUint16(port_val, 10, 0, (const char *)port) < 0)
return false;
return true;
return StringParseUint16(port_val, 10, 0, (const char *)port) >= 0;
}
/********************** End parsing routines ********************/

@ -477,10 +477,7 @@ bool SigGroupHeadEqual(const SigGroupHead *sgha, const SigGroupHead *sghb)
if (sgha->init->max_sig_id != sghb->init->max_sig_id)
return false;
if (SCMemcmp(sgha->init->sig_array, sghb->init->sig_array, sgha->init->sig_size) != 0)
return false;
return true;
return SCMemcmp(sgha->init->sig_array, sghb->init->sig_array, sgha->init->sig_size) == 0;
}
void SigGroupHeadSetProtoAndDirection(SigGroupHead *sgh,

@ -790,7 +790,7 @@ static int DetectTagTestPacket02 (void)
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 4);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);
@ -892,7 +892,7 @@ static int DetectTagTestPacket03 (void)
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 2 || i == 4);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);
@ -1006,7 +1006,7 @@ static int DetectTagTestPacket04 (void)
SCLogDebug("packet %d flag %s", i, p[i]->flags & PKT_HAS_TAG ? "true" : "false");
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 2 || i == 3);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);
@ -1132,7 +1132,7 @@ static int DetectTagTestPacket05 (void)
SCLogDebug("packet %d flag %s", i, p[i]->flags & PKT_HAS_TAG ? "true" : "false");
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 2 || i == 3 || i == 4);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);
@ -1254,7 +1254,7 @@ static int DetectTagTestPacket06 (void)
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 2);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);
@ -1375,7 +1375,7 @@ static int DetectTagTestPacket07 (void)
/* see if the PKT_HAS_TAG is set on the packet if needed */
bool expect = (i == 1 || i == 2 || i == 3 || i == 4 || i == 5);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) ? true : false) != expect);
FAIL_IF(((p[i]->flags & PKT_HAS_TAG) != 0) != expect);
}
UTHFreePackets(p, 7);

@ -327,10 +327,7 @@ static bool ThresholdEntryExpire(void *data, const SCTime_t ts)
{
const ThresholdEntry *e = data;
const SCTime_t entry = SCTIME_ADD_SECS(e->tv1, e->seconds);
if (SCTIME_CMP_GT(ts, entry)) {
return true;
}
return false;
return SCTIME_CMP_GT(ts, entry);
}
static int ThresholdsInit(struct Thresholds *t)

@ -98,9 +98,7 @@ void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx)
bool PrefilterPacketU8Compare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectUintData_u8 *a = smctx;
if (v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2)
return true;
return false;
return v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2;
}
// same as u32 but with u16
@ -134,9 +132,7 @@ void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectUintData_u16 *a = smctx;
if (v.u8[0] == a->mode && v.u16[1] == a->arg1 && v.u16[2] == a->arg2)
return true;
return false;
return v.u8[0] == a->mode && v.u16[1] == a->arg1 && v.u16[2] == a->arg2;
}
int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)

@ -114,9 +114,7 @@ static void PrefilterPacketFlowElephantSet(PrefilterPacketHeaderValue *v, void *
static bool PrefilterPacketFlowElephantCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectFlowDir *a = smctx;
if (v.u8[0] == *a)
return true;
return false;
return v.u8[0] == *a;
}
static int PrefilterSetupFlowElephant(DetectEngineCtx *de_ctx, SigGroupHead *sgh)

@ -119,11 +119,8 @@ static void PrefilterPacketFlowPktsSet(PrefilterPacketHeaderValue *v, void *smct
static bool PrefilterPacketFlowPktsCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectFlowPkts *df = smctx;
if (v.u8[0] == df->pkt_data.mode && v.u8[1] == df->dir && v.u32[1] == df->pkt_data.arg1 &&
v.u32[2] == df->pkt_data.arg2) {
return true;
}
return false;
return v.u8[0] == df->pkt_data.mode && v.u8[1] == df->dir && v.u32[1] == df->pkt_data.arg1 &&
v.u32[2] == df->pkt_data.arg2;
}
static void PrefilterPacketFlowPktsMatch(

@ -497,10 +497,7 @@ static bool
PrefilterPacketFlowCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectFlowData *fb = smctx;
if (v.u16[0] == fb->flags && v.u16[1] == fb->match_cnt) {
return true;
}
return false;
return v.u16[0] == fb->flags && v.u16[1] == fb->match_cnt;
}
static int PrefilterSetupFlow(DetectEngineCtx *de_ctx, SigGroupHead *sgh)

@ -1131,13 +1131,8 @@ error:
static bool IsBuiltIn(const char *n)
{
if (strcmp(n, "request_started") == 0 || strcmp(n, "response_started") == 0) {
return true;
}
if (strcmp(n, "request_complete") == 0 || strcmp(n, "response_complete") == 0) {
return true;
}
return false;
return strcmp(n, "request_started") == 0 || strcmp(n, "response_started") == 0 ||
strcmp(n, "request_complete") == 0 || strcmp(n, "response_complete") == 0;
}
/** \brief register app hooks as generic lists

@ -204,9 +204,7 @@ static void PrefilterPacketStreamSizeSet(PrefilterPacketHeaderValue *v, void *sm
static bool PrefilterPacketStreamSizeCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectStreamSizeData *a = smctx;
if (v.u8[0] == a->du32.mode && v.u8[1] == a->flags && v.u32[2] == a->du32.arg1)
return true;
return false;
return v.u8[0] == a->du32.mode && v.u8[1] == a->flags && v.u32[2] == a->du32.arg1;
}
static int PrefilterSetupStreamSize(DetectEngineCtx *de_ctx, SigGroupHead *sgh)

@ -224,9 +224,7 @@ static bool
PrefilterPacketFlagsCompare(PrefilterPacketHeaderValue v, void *smctx)
{
const DetectU8Data *a = smctx;
if (v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2)
return true;
return false;
return v.u8[0] == a->mode && v.u8[1] == a->arg1 && v.u8[2] == a->arg2;
}
static int PrefilterSetupTcpFlags(DetectEngineCtx *de_ctx, SigGroupHead *sgh)

@ -259,10 +259,7 @@ static bool PcapLogCondition(ThreadVars *tv, void *thread_data, const Packet *p)
return false;
}
if (PacketIsTunnelChild(p)) {
return false;
}
return true;
return !PacketIsTunnelChild(p);
}
/**

@ -338,12 +338,12 @@ static int EveStreamLogger(ThreadVars *tv, void *thread_data, const Packet *p)
SCJbSetUint(js, "tcpseq", TCP_GET_RAW_SEQ(tcph));
SCJbSetUint(js, "tcpack", TCP_GET_RAW_ACK(tcph));
SCJbSetUint(js, "tcpwin", TCP_GET_RAW_WINDOW(tcph));
SCJbSetBool(js, "syn", TCP_ISSET_FLAG_RAW_SYN(tcph) ? true : false);
SCJbSetBool(js, "ack", TCP_ISSET_FLAG_RAW_ACK(tcph) ? true : false);
SCJbSetBool(js, "psh", TCP_ISSET_FLAG_RAW_PUSH(tcph) ? true : false);
SCJbSetBool(js, "rst", TCP_ISSET_FLAG_RAW_RST(tcph) ? true : false);
SCJbSetBool(js, "urg", TCP_ISSET_FLAG_RAW_URG(tcph) ? true : false);
SCJbSetBool(js, "fin", TCP_ISSET_FLAG_RAW_FIN(tcph) ? true : false);
SCJbSetBool(js, "syn", TCP_ISSET_FLAG_RAW_SYN(tcph));
SCJbSetBool(js, "ack", TCP_ISSET_FLAG_RAW_ACK(tcph));
SCJbSetBool(js, "psh", TCP_ISSET_FLAG_RAW_PUSH(tcph));
SCJbSetBool(js, "rst", TCP_ISSET_FLAG_RAW_RST(tcph));
SCJbSetBool(js, "urg", TCP_ISSET_FLAG_RAW_URG(tcph));
SCJbSetBool(js, "fin", TCP_ISSET_FLAG_RAW_FIN(tcph));
SCJbSetUint(js, "tcpres", TCP_GET_RAW_X2(tcph));
SCJbSetUint(js, "tcpurgp", TCP_GET_RAW_URG_POINTER(tcph));

@ -129,12 +129,12 @@ static int DropLogJSON(ThreadVars *tv, JsonDropLogThread *aft, const Packet *p)
SCJbSetUint(js, "tcpseq", TCP_GET_RAW_SEQ(tcph));
SCJbSetUint(js, "tcpack", TCP_GET_RAW_ACK(tcph));
SCJbSetUint(js, "tcpwin", TCP_GET_RAW_WINDOW(tcph));
SCJbSetBool(js, "syn", TCP_ISSET_FLAG_RAW_SYN(tcph) ? true : false);
SCJbSetBool(js, "ack", TCP_ISSET_FLAG_RAW_ACK(tcph) ? true : false);
SCJbSetBool(js, "psh", TCP_ISSET_FLAG_RAW_PUSH(tcph) ? true : false);
SCJbSetBool(js, "rst", TCP_ISSET_FLAG_RAW_RST(tcph) ? true : false);
SCJbSetBool(js, "urg", TCP_ISSET_FLAG_RAW_URG(tcph) ? true : false);
SCJbSetBool(js, "fin", TCP_ISSET_FLAG_RAW_FIN(tcph) ? true : false);
SCJbSetBool(js, "syn", TCP_ISSET_FLAG_RAW_SYN(tcph));
SCJbSetBool(js, "ack", TCP_ISSET_FLAG_RAW_ACK(tcph));
SCJbSetBool(js, "psh", TCP_ISSET_FLAG_RAW_PUSH(tcph));
SCJbSetBool(js, "rst", TCP_ISSET_FLAG_RAW_RST(tcph));
SCJbSetBool(js, "urg", TCP_ISSET_FLAG_RAW_URG(tcph));
SCJbSetBool(js, "fin", TCP_ISSET_FLAG_RAW_FIN(tcph));
SCJbSetUint(js, "tcpres", TCP_GET_RAW_X2(tcph));
SCJbSetUint(js, "tcpurgp", TCP_GET_RAW_URG_POINTER(tcph));
}

@ -342,9 +342,7 @@ static void JsonTlsLogChain(SCJsonBuilder *js, SSLStateConnp *connp)
static bool HasClientCert(SSLStateConnp *connp)
{
if (connp->cert0_subject || connp->cert0_issuerdn)
return true;
return false;
return connp->cert0_subject || connp->cert0_issuerdn;
}
static void JsonTlsLogClientCert(

@ -225,10 +225,7 @@ static void EveAddPacketVars(const Packet *p, SCJsonBuilder *js_vars)
*/
static bool SCStringHasPrefix(const char *s, const char *prefix)
{
if (strncmp(s, prefix, strlen(prefix)) == 0) {
return true;
}
return false;
return strncmp(s, prefix, strlen(prefix)) == 0;
}
static void EveAddFlowVars(const Flow *f, SCJsonBuilder *js_root, SCJsonBuilder **js_traffic)

@ -906,7 +906,7 @@ static int ConfigLoad(DPDKIfaceConfig *iconf, const char *iface)
if (retval != 1) {
irq_enable = DPDK_CONFIG_DEFAULT_INTERRUPT_MODE;
} else {
irq_enable = entry_bool ? true : false;
irq_enable = entry_bool;
}
retval = ConfigSetInterruptMode(iconf, irq_enable);
if (retval != true)

@ -656,7 +656,7 @@ static TmEcode ReceiveDPDKThreadInit(ThreadVars *tv, const void *initdata, void
ptv->checksum_mode = dpdk_config->checksum_mode;
ptv->threads = dpdk_config->threads;
ptv->intr_enabled = (dpdk_config->flags & DPDK_IRQ_MODE) ? true : false;
ptv->intr_enabled = (dpdk_config->flags & DPDK_IRQ_MODE) != 0;
ptv->port_id = dpdk_config->port_id;
ptv->out_port_id = dpdk_config->out_port_id;
ptv->port_socket_id = dpdk_config->socket_id;

@ -634,7 +634,7 @@ bool StreamTcpReassembleDepthReached(Packet *p)
stream = &ssn->server;
}
return (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) ? true : false;
return (stream->flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED) != 0;
}
return false;
@ -1099,11 +1099,8 @@ static inline bool GapAhead(const TcpStream *stream, StreamingBufferBlock *cur_b
StreamingBufferBlock *nblk = SBB_RB_NEXT(cur_blk);
/* only if the stream has been ack'd, consider a gap for sure
* otherwise there may still be a chance of pkts coming in */
if (nblk && (cur_blk->offset + cur_blk->len < nblk->offset) &&
GetAbsLastAck(stream) > (cur_blk->offset + cur_blk->len)) {
return true;
}
return false;
return nblk && (cur_blk->offset + cur_blk->len < nblk->offset) &&
GetAbsLastAck(stream) > (cur_blk->offset + cur_blk->len);
}
/** \internal

@ -150,9 +150,7 @@ static inline bool STREAM_LASTACK_GT_BASESEQ(const TcpStream *stream)
return false;
#endif
}
if (SEQ_GT(stream->last_ack, stream->base_seq))
return true;
return false;
return SEQ_GT(stream->last_ack, stream->base_seq);
}
uint32_t StreamDataAvailableForProtoDetect(TcpStream *stream);

@ -7103,7 +7103,7 @@ void StreamTcpDetectLogFlush(ThreadVars *tv, StreamTcpThread *stt, Flow *f, Pack
TcpSession *ssn = f->protoctx;
ssn->client.flags |= STREAMTCP_STREAM_FLAG_TRIGGER_RAW;
ssn->server.flags |= STREAMTCP_STREAM_FLAG_TRIGGER_RAW;
bool ts = PKT_IS_TOSERVER(p) ? true : false;
bool ts = PKT_IS_TOSERVER(p);
ts ^= StreamTcpInlineMode();
StreamTcpPseudoPacketCreateDetectLogFlush(tv, stt, p, ssn, pq, ts^0);
StreamTcpPseudoPacketCreateDetectLogFlush(tv, stt, p, ssn, pq, ts^1);

@ -1379,9 +1379,7 @@ static int ParseCommandLinePcapLive(SCInstance *suri, const char *in_arg)
*/
static bool IsLogDirectoryWritable(const char* str)
{
if (access(str, W_OK) == 0)
return true;
return false;
return access(str, W_OK) == 0;
}
extern int g_skip_prefilter;

@ -64,7 +64,7 @@ void FlowRateRegisterFlowStorage(void)
return;
bool track_flow = false;
track_flow = SCConfNodeLookupChild(root, "rate-tracking") != NULL ? true : false;
track_flow = SCConfNodeLookupChild(root, "rate-tracking") != NULL;
if (!track_flow)
return;
@ -227,10 +227,7 @@ void FlowRateStoreUpdate(FlowRateStore *frs, SCTime_t p_ts, uint32_t pkt_len, in
bool FlowRateIsExceeding(FlowRateStore *frs, int direction)
{
if (frs->dir[direction].sum >= flow_rate_config.bytes) {
return true;
}
return false;
return frs->dir[direction].sum >= flow_rate_config.bytes;
}
#ifdef UNITTESTS

@ -54,9 +54,7 @@ static OSHugepageAction SystemHugepageDetermineOS(void)
static bool SystemHugepageSupported(void)
{
if (SystemHugepageDetermineOS() != OS_UNKNOWN)
return true;
return false;
return SystemHugepageDetermineOS() != OS_UNKNOWN;
}
/**

@ -24,10 +24,7 @@
static bool LuaGetAr(lua_State *L, lua_Debug *ar)
{
if (lua_getstack(L, 1, ar) && lua_getinfo(L, "nSl", ar)) {
return true;
}
return false;
return lua_getstack(L, 1, ar) && lua_getinfo(L, "nSl", ar);
}
static int LuaLogInfo(lua_State *L)

@ -397,11 +397,7 @@ static bool HSPruneFileByVersion(const char *filename)
}
const char *underscore = strrchr(filename, '_');
if (underscore == NULL || strcmp(underscore, HS_CACHE_FILE_SUFFIX) != 0) {
return true;
}
return false;
return underscore == NULL || strcmp(underscore, HS_CACHE_FILE_SUFFIX) != 0;
}
int SCHSCachePruneEvaluate(MpmConfig *mpm_conf, HashTable *inuse_caches)

@ -183,10 +183,7 @@ int SCCreateDirectoryTree(const char *path, const bool final)
bool SCPathExists(const char *path)
{
struct stat sb;
if (stat(path, &sb) == 0) {
return true;
}
return false;
return stat(path, &sb) == 0;
}
/**

@ -58,10 +58,7 @@ static int PoolMemset(void *pitem, void *initdata)
static bool PoolDataPreAllocated(Pool *p, void *data)
{
ptrdiff_t delta = data - p->data_buffer;
if ((delta < 0) || (delta > p->data_buffer_size)) {
return false;
}
return true;
return delta >= 0 && delta <= p->data_buffer_size;
}
/** \brief Init a Pool

@ -949,8 +949,7 @@ static bool CompareTreesSub(
if (!CompareTreesSub(n1->left, n2->left, Callback))
return false;
if (n1->right && n2->right)
if (!CompareTreesSub(n1->right, n2->right, Callback))
return false;
return CompareTreesSub(n1->right, n2->right, Callback);
return true;
}

@ -71,13 +71,8 @@ int ListRuleProtocols(const char *conf_filename)
static bool IsBuiltIn(const char *n)
{
if (strcmp(n, "request_started") == 0 || strcmp(n, "response_started") == 0) {
return true;
}
if (strcmp(n, "request_complete") == 0 || strcmp(n, "response_complete") == 0) {
return true;
}
return false;
return strcmp(n, "request_started") == 0 || strcmp(n, "response_started") == 0 ||
strcmp(n, "request_complete") == 0 || strcmp(n, "response_complete") == 0;
}
int ListAppLayerHooks(const char *conf_filename)

@ -141,10 +141,7 @@ static inline bool RegionsIntersect(const StreamingBufferConfig *cfg,
* re < reg_o or if reg_re < offset (one segment is strictly before the other)
* trusting that offset<=re and reg_o<=reg_re
*/
if (re < reg_o || reg_re < offset) {
return false;
}
return true;
return re >= reg_o && reg_re >= offset;
}
/** \internal

Loading…
Cancel
Save