diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index dfcd2938d3ab..e0a0802051e1 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -468,9 +468,9 @@ static OutputInitResult AlertDebugLogInitCtx(ConfNode *conf) return result; } -static int AlertDebugLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool AlertDebugLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { - return (p->alerts.cnt ? TRUE : FALSE); + return (p->alerts.cnt > 0); } static int AlertDebugLogLogger(ThreadVars *tv, void *thread_data, const Packet *p) diff --git a/src/alert-fastlog.c b/src/alert-fastlog.c index bfb7f8ffe8c4..8cd4a3c58aa8 100644 --- a/src/alert-fastlog.c +++ b/src/alert-fastlog.c @@ -71,7 +71,7 @@ TmEcode AlertFastLogThreadDeinit(ThreadVars *, void *); void AlertFastLogRegisterTests(void); static void AlertFastLogDeInitCtx(OutputCtx *); -int AlertFastLogCondition(ThreadVars *tv, void *thread_data, const Packet *p); +static bool AlertFastLogCondition(ThreadVars *tv, void *thread_data, const Packet *p); int AlertFastLogger(ThreadVars *tv, void *data, const Packet *p); void AlertFastLogRegister(void) @@ -87,9 +87,9 @@ typedef struct AlertFastLogThread_ { LogFileCtx* file_ctx; } AlertFastLogThread; -int AlertFastLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool AlertFastLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { - return (p->alerts.cnt ? TRUE : FALSE); + return (p->alerts.cnt > 0); } static inline void AlertFastLogOutputAlert(AlertFastLogThread *aft, char *buffer, diff --git a/src/alert-syslog.c b/src/alert-syslog.c index fa585811bb5d..df0be1a94a63 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -367,9 +367,9 @@ static TmEcode AlertSyslogDecoderEvent(ThreadVars *tv, const Packet *p, void *da return TM_ECODE_OK; } -static int AlertSyslogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool AlertSyslogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { - return (p->alerts.cnt > 0 ? TRUE : FALSE); + return (p->alerts.cnt > 0); } static int AlertSyslogLogger(ThreadVars *tv, void *thread_data, const Packet *p) diff --git a/src/app-layer-htp-libhtp.c b/src/app-layer-htp-libhtp.c index 2fbd5eae3390..dcc4a92b8bb0 100644 --- a/src/app-layer-htp-libhtp.c +++ b/src/app-layer-htp-libhtp.c @@ -61,7 +61,7 @@ * \param uri_include_all boolean to indicate if scheme, username/password, hostname and port should be part of the buffer */ -bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, int uri_include_all) +bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, bool uri_include_all) { if (uri == NULL) return NULL; diff --git a/src/app-layer-htp-libhtp.h b/src/app-layer-htp-libhtp.h index 574dda4134dc..b08cda508ece 100644 --- a/src/app-layer-htp-libhtp.h +++ b/src/app-layer-htp-libhtp.h @@ -48,6 +48,6 @@ #include "suricata-common.h" -bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, int uri_include_all); +bstr *SCHTPGenerateNormalizedUri(htp_tx_t *tx, htp_uri_t *uri, bool uri_include_all); #endif /* __APP_LAYER_HTP_LIBHTP__H__ */ diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index b576ba3b7b97..000fc88bbd0c 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2463,7 +2463,7 @@ static int HTPCallbackResponseHeaderData(htp_tx_data_t *tx_data) */ static void HTPConfigSetDefaultsPhase1(HTPCfgRec *cfg_prec) { - cfg_prec->uri_include_all = FALSE; + cfg_prec->uri_include_all = false; cfg_prec->request.body_limit = HTP_CONFIG_DEFAULT_REQUEST_BODY_LIMIT; cfg_prec->response.body_limit = HTP_CONFIG_DEFAULT_RESPONSE_BODY_LIMIT; cfg_prec->request.inspect_min_size = HTP_CONFIG_DEFAULT_REQUEST_INSPECT_MIN_SIZE; @@ -2785,7 +2785,7 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s, HTP_DECODER_URL_PATH, ConfValIsTrue(p->val)); } else if (strcasecmp("uri-include-all", p->name) == 0) { - cfg_prec->uri_include_all = ConfValIsTrue(p->val); + cfg_prec->uri_include_all = (1 == ConfValIsTrue(p->val)); SCLogDebug("uri-include-all %s", cfg_prec->uri_include_all ? "enabled" : "disabled"); } else if (strcasecmp("query-plusspace-decode", p->name) == 0) { diff --git a/src/app-layer-htp.h b/src/app-layer-htp.h index c8c3a7f7b987..dee5c17e833e 100644 --- a/src/app-layer-htp.h +++ b/src/app-layer-htp.h @@ -157,8 +157,6 @@ typedef struct HTPCfgRec_ { htp_cfg_t *cfg; struct HTPCfgRec_ *next; - int uri_include_all; /**< use all info in uri (bool) */ - /** max size of the client body we inspect */ int randomize; int randomize_range; @@ -171,6 +169,8 @@ typedef struct HTPCfgRec_ { HTPCfgDir request; HTPCfgDir response; + + bool uri_include_all; /**< use all info in uri (bool) */ } HTPCfgRec; /** Struct used to hold chunks of a body on a request */ diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index 7783c076b65b..572e15f628cc 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1184,16 +1184,14 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f, SCReturnCT(active_id, "uint64_t"); } -int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto) +bool AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto) { // Custom case for only signature-only protocol so far if (alproto == ALPROTO_HTTP) { return AppLayerParserSupportsFiles(ipproto, ALPROTO_HTTP1) || AppLayerParserSupportsFiles(ipproto, ALPROTO_HTTP2); } - if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxFiles != NULL) - return TRUE; - return FALSE; + return alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].GetTxFiles != NULL; } AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx) diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index d27a08c85119..e9f8cf55e925 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -253,7 +253,7 @@ uint64_t AppLayerParserGetTransactionActive(const Flow *f, AppLayerParserState * uint8_t AppLayerParserGetFirstDataDir(uint8_t ipproto, AppProto alproto); -int AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto); +bool AppLayerParserSupportsFiles(uint8_t ipproto, AppProto alproto); AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx); uint64_t AppLayerParserGetTxDetectFlags(AppLayerTxData *txd, const uint8_t dir); diff --git a/src/app-layer-ssh.c b/src/app-layer-ssh.c index 0cf404c8736e..71bc786ad6b4 100644 --- a/src/app-layer-ssh.c +++ b/src/app-layer-ssh.c @@ -71,7 +71,7 @@ static int SSHRegisterPatternsForProtocolDetection(void) return 0; } -int SSHTxLogCondition(ThreadVars * tv, const Packet * p, void *state, void *tx, uint64_t tx_id) +bool SSHTxLogCondition(ThreadVars *tv, const Packet *p, void *state, void *tx, uint64_t tx_id) { return rs_ssh_tx_get_log_condition(tx); } diff --git a/src/app-layer-ssh.h b/src/app-layer-ssh.h index 8dbb3be817ef..996cc260c735 100644 --- a/src/app-layer-ssh.h +++ b/src/app-layer-ssh.h @@ -28,7 +28,7 @@ void RegisterSSHParsers(void); void SSHParserRegisterTests(void); -int SSHTxLogCondition(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id); +bool SSHTxLogCondition(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id); #endif /* __APP_LAYER_SSH_H__ */ diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index ac10e142dedc..7819969e6ef3 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -1842,12 +1842,12 @@ DetectAddress *DetectAddressLookupInHead(const DetectAddressHead *gh, Address *a #ifdef UNITTESTS -static int UTHValidateDetectAddress(DetectAddress *ad, const char *one, const char *two) +static bool UTHValidateDetectAddress(DetectAddress *ad, const char *one, const char *two) { char str1[46] = "", str2[46] = ""; if (ad == NULL) - return FALSE; + return false; switch(ad->ip.family) { case AF_INET: @@ -1858,15 +1858,15 @@ static int UTHValidateDetectAddress(DetectAddress *ad, const char *one, const ch if (strcmp(str1, one) != 0) { SCLogInfo("%s != %s", str1, one); - return FALSE; + return false; } if (strcmp(str2, two) != 0) { SCLogInfo("%s != %s", str2, two); - return FALSE; + return false; } - return TRUE; + return true; break; case AF_INET6: @@ -1877,19 +1877,19 @@ static int UTHValidateDetectAddress(DetectAddress *ad, const char *one, const ch if (strcmp(str1, one) != 0) { SCLogInfo("%s != %s", str1, one); - return FALSE; + return false; } if (strcmp(str2, two) != 0) { SCLogInfo("%s != %s", str2, two); - return FALSE; + return false; } - return TRUE; + return true; break; } - return FALSE; + return false; } typedef struct UTHValidateDetectAddressHeadRange_ { @@ -1903,7 +1903,7 @@ static int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHV int have = 0; if (gh == NULL) - return FALSE; + return false; DetectAddress *ad = NULL; ad = gh->ipv4_head; @@ -1912,17 +1912,17 @@ static int UTHValidateDetectAddressHead(DetectAddressHead *gh, int nranges, UTHV while (have < expect) { if (ad == NULL) { printf("bad head: have %d ranges, expected %d: ", have, expect); - return FALSE; + return false; } - if (UTHValidateDetectAddress(ad, expectations[have].one, expectations[have].two) == FALSE) - return FALSE; + if (!UTHValidateDetectAddress(ad, expectations[have].one, expectations[have].two)) + return false; ad = ad->next; have++; } - return TRUE; + return true; } static int AddressTestParse01(void) @@ -4130,7 +4130,7 @@ static int AddressTestAddressGroupSetup38(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "![192.168.0.0/16,!192.168.14.0/24]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 3, expectations)) result = 1; } @@ -4151,7 +4151,7 @@ static int AddressTestAddressGroupSetup39(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,!192.168.14.0/24]]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 3, expectations)) result = 1; } @@ -4171,7 +4171,7 @@ static int AddressTestAddressGroupSetup40(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,[!192.168.14.0/24]]]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 3, expectations)) result = 1; } @@ -4191,7 +4191,7 @@ static int AddressTestAddressGroupSetup41(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.14.0/24]]]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 3, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 3, expectations)) result = 1; } @@ -4209,7 +4209,7 @@ static int AddressTestAddressGroupSetup42(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[2001::/3]"); if (r == 0) { - if (UTHValidateDetectAddressHead(gh, 1, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 1, expectations)) result = 1; } @@ -4228,7 +4228,7 @@ static int AddressTestAddressGroupSetup43(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[2001::/3,!3000::/5]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 2, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 2, expectations)) result = 1; } @@ -4246,7 +4246,7 @@ static int AddressTestAddressGroupSetup44(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "3ffe:ffff:7654:feda:1245:ba98:3210:4562/96"); if (r == 0) { - if (UTHValidateDetectAddressHead(gh, 1, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 1, expectations)) result = 1; } @@ -4282,7 +4282,7 @@ static int AddressTestAddressGroupSetup46(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24]]]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 4, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 4, expectations)) result = 1; } @@ -4305,7 +4305,7 @@ static int AddressTestAddressGroupSetup47(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[![192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24],!192.168.5.0/24]]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 5, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 5, expectations)) result = 1; } @@ -4327,7 +4327,7 @@ static int AddressTestAddressGroupSetup48(void) if (gh != NULL) { int r = DetectAddressParse(NULL, gh, "[192.168.0.0/16,![192.168.1.0/24,192.168.3.0/24],!192.168.5.0/24]"); if (r == 1) { - if (UTHValidateDetectAddressHead(gh, 4, expectations) == TRUE) + if (UTHValidateDetectAddressHead(gh, 4, expectations)) result = 1; } diff --git a/src/detect-engine-loader.c b/src/detect-engine-loader.c index 3ef29b9b40f1..053e162068c0 100644 --- a/src/detect-engine-loader.c +++ b/src/detect-engine-loader.c @@ -270,7 +270,7 @@ static int ProcessSigFiles(DetectEngineCtx *de_ctx, char *pattern, * \param sig_file_exclusive File passed in 'sig_file' should be loaded exclusively. * \retval -1 on error */ -int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_exclusive) +int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, bool sig_file_exclusive) { SCEnter(); @@ -293,7 +293,7 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl } /* ok, let's load signature files from the general config */ - if (!(sig_file != NULL && sig_file_exclusive == TRUE)) { + if (!(sig_file != NULL && sig_file_exclusive)) { rule_files = ConfGetNode(varname); if (rule_files != NULL) { if (!ConfNodeIsSequence(rule_files)) { diff --git a/src/detect-engine-prefilter.c b/src/detect-engine-prefilter.c index fd1b691ee2d9..f283e180b670 100644 --- a/src/detect-engine-prefilter.c +++ b/src/detect-engine-prefilter.c @@ -453,7 +453,7 @@ void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh) el->pectx = NULL; // e now owns the ctx e->gid = el->gid; if (el->next == NULL) { - e->is_last = TRUE; + e->is_last = true; } e++; } @@ -477,7 +477,7 @@ void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh) el->pectx = NULL; // e now owns the ctx e->gid = el->gid; if (el->next == NULL) { - e->is_last = TRUE; + e->is_last = true; } e++; } @@ -579,7 +579,7 @@ void PrefilterSetupRuleGroup(DetectEngineCtx *de_ctx, SigGroupHead *sgh) el->pectx = NULL; // e now owns the ctx e->gid = el->gid; if (el->next == NULL) { - e->is_last = TRUE; + e->is_last = true; } e++; } diff --git a/src/detect-engine.c b/src/detect-engine.c index d8f9f1880e56..a60b9dc6777c 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -3858,7 +3858,7 @@ static int DetectEngineMultiTenantLoadTenant(uint32_t tenant_id, const char *fil goto error; } - if (SigLoadSignatures(de_ctx, NULL, 0) < 0) { + if (SigLoadSignatures(de_ctx, NULL, false) < 0) { SCLogError("Loading signatures failed."); goto error; } @@ -3918,7 +3918,7 @@ static int DetectEngineMultiTenantReloadTenant(uint32_t tenant_id, const char *f goto error; } - if (SigLoadSignatures(new_de_ctx, NULL, 0) < 0) { + if (SigLoadSignatures(new_de_ctx, NULL, false) < 0) { SCLogError("Loading signatures failed."); goto error; } diff --git a/src/detect-parse.c b/src/detect-parse.c index d9800f0a2f34..bf54f9359a0e 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -128,7 +128,7 @@ void DetectFileRegisterFileProtocols(DetectFileHandlerTableElmt *reg) /* Table with all SigMatch registrations */ SigTableElmt sigmatch_table[DETECT_TBLSIZE]; -extern int sc_set_caps; +extern bool sc_set_caps; static void SigMatchTransferSigMatchAcrossLists(SigMatch *sm, SigMatch **src_sm_list, SigMatch **src_sm_list_tail, @@ -1174,7 +1174,7 @@ static int SigParseActionRejectValidate(const char *action) { #ifdef HAVE_LIBNET11 #if defined HAVE_LIBCAP_NG && !defined HAVE_LIBNET_CAPABILITIES - if (sc_set_caps == TRUE) { + if (sc_set_caps) { SCLogError("Libnet 1.1 is " "incompatible with POSIX based capabilities with privs dropping. " "For rejects to work, run as root/super user."); diff --git a/src/detect.h b/src/detect.h index 04dd49a65a75..892c6a0ef2a4 100644 --- a/src/detect.h +++ b/src/detect.h @@ -1560,7 +1560,7 @@ void SigRegisterTests(void); void DisableDetectFlowFileFlags(Flow *f); char *DetectLoadCompleteSigPath(const DetectEngineCtx *, const char *sig_file); -int SigLoadSignatures (DetectEngineCtx *, char *, int); +int SigLoadSignatures(DetectEngineCtx *, char *, bool); void SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, Packet *p); diff --git a/src/log-pcap.c b/src/log-pcap.c index 1e1b6da1fb55..f8c8bf716562 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -141,7 +141,6 @@ typedef struct PcapLogCompressionData_ { typedef struct PcapLogData_ { int use_stream_depth; /**< use stream depth i.e. ignore packets that reach limit */ int honor_pass_rules; /**< don't log if pass rules have matched */ - int is_private; /**< TRUE if ctx is thread local */ SCMutex plog_lock; uint64_t pkt_cnt; /**< total number of packets */ struct pcap_pkthdr *h; /**< pcap header struct */ @@ -155,6 +154,7 @@ typedef struct PcapLogData_ { uint64_t profile_data_size; /**< track in bytes how many bytes we wrote */ uint32_t file_cnt; /**< count of pcap files we currently have */ uint32_t max_files; /**< maximum files to use in ring buffer mode */ + bool is_private; /**< true if ctx is thread local */ LogModeConditionalType conditional; /**< log all packets or just packets and flows with alerts */ @@ -206,7 +206,7 @@ static TmEcode PcapLogDataDeinit(ThreadVars *, void *); static void PcapLogFileDeInitCtx(OutputCtx *); static OutputInitResult PcapLogInitCtx(ConfNode *); static void PcapLogProfilingDump(PcapLogData *); -static int PcapLogCondition(ThreadVars *, void *, const Packet *); +static bool PcapLogCondition(ThreadVars *, void *, const Packet *); void PcapLogRegister(void) { @@ -226,7 +226,7 @@ void PcapLogRegister(void) (prof).total += (UtilCpuGetTicks() - pcaplog_profile_ticks); \ (prof).cnt++ -static int PcapLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool PcapLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { PcapLogThreadData *ptd = (PcapLogThreadData *)thread_data; @@ -235,29 +235,21 @@ static int PcapLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) case LOGMODE_COND_ALL: break; case LOGMODE_COND_ALERTS: - if (p->alerts.cnt || (p->flow && FlowHasAlerts(p->flow))) { - return TRUE; - } else { - return FALSE; - } + return (p->alerts.cnt || (p->flow && FlowHasAlerts(p->flow))); break; case LOGMODE_COND_TAG: - if (p->flags & (PKT_HAS_TAG | PKT_FIRST_TAG)) { - return TRUE; - } else { - return FALSE; - } + return (p->flags & (PKT_HAS_TAG | PKT_FIRST_TAG)); break; } if (p->flags & PKT_PSEUDO_STREAM_END) { - return FALSE; + return false; } if (IS_TUNNEL_PKT(p) && !IS_TUNNEL_ROOT_PKT(p)) { - return FALSE; + return false; } - return TRUE; + return true; } /** @@ -771,7 +763,7 @@ static PcapLogData *PcapLogDataCopy(const PcapLogData *pl) copy->suffix = pl->suffix; /* settings TODO move to global cfg struct */ - copy->is_private = TRUE; + copy->is_private = true; copy->mode = pl->mode; copy->max_files = pl->max_files; copy->use_ringbuffer = pl->use_ringbuffer; diff --git a/src/log-tlsstore.c b/src/log-tlsstore.c index 4e1d54a5fe3a..969044553673 100644 --- a/src/log-tlsstore.c +++ b/src/log-tlsstore.c @@ -226,15 +226,15 @@ static void LogTlsLogPem(LogTlsStoreLogThread *aft, const Packet *p, SSLState *s * \brief Condition function for TLS logger * \retval bool true or false -- log now? */ -static int LogTlsStoreCondition(ThreadVars *tv, const Packet *p, void *state, - void *tx, uint64_t tx_id) +static bool LogTlsStoreCondition( + ThreadVars *tv, const Packet *p, void *state, void *tx, uint64_t tx_id) { if (p->flow == NULL) { - return FALSE; + return false; } if (!(PKT_IS_TCP(p))) { - return FALSE; + return false; } SSLState *ssl_state = (SSLState *)state; @@ -250,9 +250,9 @@ static int LogTlsStoreCondition(ThreadVars *tv, const Packet *p, void *state, ssl_state->server_connp.cert0_subject == NULL) goto dontlog; - return TRUE; + return true; dontlog: - return FALSE; + return false; } static int LogTlsStoreLogger(ThreadVars *tv, void *thread_data, const Packet *p, diff --git a/src/output-eve-stream.c b/src/output-eve-stream.c index 446fb3e60e18..919505dce70d 100644 --- a/src/output-eve-stream.c +++ b/src/output-eve-stream.c @@ -282,7 +282,7 @@ static void LogStream(const TcpStream *stream, JsonBuilder *js) * \param data Pointer to the EveStreamLogThread struct * \param p Pointer the packet which is being logged * - * \retval 0 on succes + * \retval 0 on success */ static int EveStreamLogger(ThreadVars *tv, void *thread_data, const Packet *p) { @@ -422,9 +422,9 @@ static int EveStreamLogger(ThreadVars *tv, void *thread_data, const Packet *p) * \param tv Pointer the current thread variables * \param p Pointer the packet which is tested * - * \retval bool TRUE or FALSE + * \retval bool true or false */ -static int EveStreamLogCondition(ThreadVars *tv, void *data, const Packet *p) +static bool EveStreamLogCondition(ThreadVars *tv, void *data, const Packet *p) { EveStreamLogThread *td = data; EveStreamOutputCtx *ctx = td->stream_ctx; diff --git a/src/output-json-alert.c b/src/output-json-alert.c index a7df1065509e..c3886231c001 100644 --- a/src/output-json-alert.c +++ b/src/output-json-alert.c @@ -947,12 +947,9 @@ static int JsonAlertLogger(ThreadVars *tv, void *thread_data, const Packet *p) return 0; } -static int JsonAlertLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool JsonAlertLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { - if (p->alerts.cnt || (p->flags & PKT_HAS_TAG)) { - return TRUE; - } - return FALSE; + return (p->alerts.cnt || (p->flags & PKT_HAS_TAG)); } static TmEcode JsonAlertLogThreadInit(ThreadVars *t, const void *initdata, void **data) diff --git a/src/output-json-anomaly.c b/src/output-json-anomaly.c index 606ead0e6224..ffe931a73ed6 100644 --- a/src/output-json-anomaly.c +++ b/src/output-json-anomaly.c @@ -279,7 +279,7 @@ static int JsonAnomalyLogger(ThreadVars *tv, void *thread_data, const Packet *p) return AnomalyJson(tv, aft, p); } -static int JsonAnomalyLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool JsonAnomalyLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { return p->events.cnt > 0 || (p->app_layer_events && p->app_layer_events->cnt > 0) || diff --git a/src/output-json-drop.c b/src/output-json-drop.c index 56484c36d43b..edce3793d100 100644 --- a/src/output-json-drop.c +++ b/src/output-json-drop.c @@ -340,49 +340,48 @@ static int JsonDropLogger(ThreadVars *tv, void *thread_data, const Packet *p) return 0; } - /** * \brief Check if we need to drop-log this packet * * \param tv Pointer the current thread variables * \param p Pointer the packet which is tested * - * \retval bool TRUE or FALSE + * \retval bool true or false */ -static int JsonDropLogCondition(ThreadVars *tv, void *data, const Packet *p) +static bool JsonDropLogCondition(ThreadVars *tv, void *data, const Packet *p) { if (!EngineModeIsIPS()) { SCLogDebug("engine is not running in inline mode, so returning"); - return FALSE; + return false; } if (PKT_IS_PSEUDOPKT(p)) { SCLogDebug("drop log doesn't log pseudo packets"); - return FALSE; + return false; } if (!(PacketCheckAction(p, ACTION_DROP))) { - return FALSE; + return false; } if (g_droplog_flows_start && p->flow != NULL) { - int ret = FALSE; + bool ret = false; /* for a flow that will be dropped fully, log just once per direction */ if (p->flow->flags & FLOW_ACTION_DROP) { if (PKT_IS_TOSERVER(p) && !(p->flow->flags & FLOW_TOSERVER_DROP_LOGGED)) - ret = TRUE; + ret = true; else if (PKT_IS_TOCLIENT(p) && !(p->flow->flags & FLOW_TOCLIENT_DROP_LOGGED)) - ret = TRUE; + ret = true; } /* if drop is caused by signature, log anyway */ if (p->alerts.drop.action != 0) - ret = TRUE; + ret = true; return ret; } - return TRUE; + return true; } void JsonDropLogRegister (void) diff --git a/src/output-json-frame.c b/src/output-json-frame.c index d23ba92ac380..b7aaabc1dea9 100644 --- a/src/output-json-frame.c +++ b/src/output-json-frame.c @@ -376,15 +376,15 @@ static int JsonFrameLogger(ThreadVars *tv, void *thread_data, const Packet *p) return FrameJson(tv, aft, p); } -static int JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) +static bool JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packet *p) { if (p->flow == NULL || p->flow->alproto == ALPROTO_UNKNOWN) - return FALSE; + return false; if ((p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP) && p->flow->alparser != NULL) { FramesContainer *frames_container = AppLayerFramesGetContainer(p->flow); if (frames_container == NULL) - return FALSE; + return false; Frames *frames; if (PKT_IS_TOSERVER(p)) { @@ -394,7 +394,7 @@ static int JsonFrameLogCondition(ThreadVars *tv, void *thread_data, const Packet } return (frames->cnt != 0); } - return FALSE; + return false; } static TmEcode JsonFrameLogThreadInit(ThreadVars *t, const void *initdata, void **data) diff --git a/src/output-json-metadata.c b/src/output-json-metadata.c index 231ff1d5d3e2..772b2ccb06f2 100644 --- a/src/output-json-metadata.c +++ b/src/output-json-metadata.c @@ -87,12 +87,9 @@ static int JsonMetadataLogger(ThreadVars *tv, void *thread_data, const Packet *p return MetadataJson(tv, aft, p); } -static int JsonMetadataLogCondition(ThreadVars *tv, void *data, const Packet *p) +static bool JsonMetadataLogCondition(ThreadVars *tv, void *data, const Packet *p) { - if (p->pktvar) { - return TRUE; - } - return FALSE; + return p->pktvar != NULL; } void JsonMetadataLogRegister (void) diff --git a/src/output-lua.c b/src/output-lua.c index cc93a2de4a54..28ba3e9f91b7 100644 --- a/src/output-lua.c +++ b/src/output-lua.c @@ -162,7 +162,7 @@ static int LuaStreamingLogger(ThreadVars *tv, void *thread_data, const Flow *f, * * A single call to this function will run one script for a single * packet. If it is called, it means that the registered condition - * function has returned TRUE. + * function has returned true. * * The script is called once for each alert stored in the packet. * @@ -215,11 +215,9 @@ static int LuaPacketLoggerAlerts(ThreadVars *tv, void *thread_data, const Packet SCReturnInt(0); } -static int LuaPacketConditionAlerts(ThreadVars *tv, void *data, const Packet *p) +static bool LuaPacketConditionAlerts(ThreadVars *tv, void *data, const Packet *p) { - if (p->alerts.cnt > 0) - return TRUE; - return FALSE; + return (p->alerts.cnt > 0); } /** \internal @@ -227,7 +225,7 @@ static int LuaPacketConditionAlerts(ThreadVars *tv, void *data, const Packet *p) * * A single call to this function will run one script for a single * packet. If it is called, it means that the registered condition - * function has returned TRUE. + * function has returned true. * * The script is called once for each packet. * @@ -265,9 +263,9 @@ static int LuaPacketLogger(ThreadVars *tv, void *thread_data, const Packet *p) SCReturnInt(0); } -static int LuaPacketCondition(ThreadVars *tv, void *data, const Packet *p) +static bool LuaPacketCondition(ThreadVars *tv, void *data, const Packet *p) { - return TRUE; + return true; } /** \internal diff --git a/src/output-packet.c b/src/output-packet.c index 232be2697e5a..d42d1033cade 100644 --- a/src/output-packet.c +++ b/src/output-packet.c @@ -105,7 +105,7 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data) while (logger && store) { DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL || logger->ConditionFunc == NULL); - if ((logger->ConditionFunc(tv, store->thread_data, (const Packet *)p)) == TRUE) { + if (logger->ConditionFunc(tv, store->thread_data, (const Packet *)p)) { PACKET_PROFILING_LOGGER_START(p, logger->logger_id); logger->LogFunc(tv, store->thread_data, (const Packet *)p); PACKET_PROFILING_LOGGER_END(p, logger->logger_id); diff --git a/src/output-packet.h b/src/output-packet.h index adba55689122..1e468669f137 100644 --- a/src/output-packet.h +++ b/src/output-packet.h @@ -32,7 +32,7 @@ typedef int (*PacketLogger)(ThreadVars *, void *thread_data, const Packet *); /** packet logger condition function pointer type, * must return true for packets that should be logged */ -typedef int (*PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *); +typedef bool (*PacketLogCondition)(ThreadVars *, void *thread_data, const Packet *); int OutputRegisterPacketLogger(LoggerId logger_id, const char *name, PacketLogger LogFunc, PacketLogCondition ConditionFunc, OutputCtx *, diff --git a/src/output-tx.c b/src/output-tx.c index 18a34e78a734..8eb6a842a656 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -299,8 +299,7 @@ static void OutputTxLogCallLoggers(ThreadVars *tv, OutputTxLoggerThreadData *op_ SCLogDebug("EOF, so log now"); } else { if (logger->LogCondition) { - int r = logger->LogCondition(tv, p, alstate, tx, tx_id); - if (r == FALSE) { + if (!logger->LogCondition(tv, p, alstate, tx, tx_id)) { SCLogDebug("conditions not met, not logging"); goto next_logger; } diff --git a/src/output-tx.h b/src/output-tx.h index 8d58156bef8d..88c12ff25f68 100644 --- a/src/output-tx.h +++ b/src/output-tx.h @@ -35,7 +35,8 @@ typedef int (*TxLogger)(ThreadVars *, void *thread_data, const Packet *, Flow *f /** tx logger condition function pointer type, * must return true for tx that should be logged */ -typedef int (*TxLoggerCondition)(ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id); +typedef bool (*TxLoggerCondition)( + ThreadVars *, const Packet *, void *state, void *tx, uint64_t tx_id); int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto, TxLogger LogFunc, diff --git a/src/respond-reject-libnet11.c b/src/respond-reject-libnet11.c index 95ff114484db..634fa3b8b545 100644 --- a/src/respond-reject-libnet11.c +++ b/src/respond-reject-libnet11.c @@ -62,7 +62,7 @@ uint16_t g_reject_dev_mtu = 0; /** set to true in main if we're setting caps. We need it here if we're using * reject rules as libnet 1.1 is not compatible with caps. */ -extern int sc_set_caps; +extern bool sc_set_caps; #include diff --git a/src/runmodes.c b/src/runmodes.c index 348adfa25d43..852155332d75 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -72,7 +72,7 @@ #include "suricata-plugin.h" int debuglog_enabled = 0; -int threading_set_cpu_affinity = FALSE; +bool threading_set_cpu_affinity = false; uint64_t threading_set_stack_size = 0; /* Runmode Global Thread Names */ @@ -982,12 +982,15 @@ float threading_detect_ratio = 1; */ void RunModeInitializeThreadSettings(void) { - threading_set_cpu_affinity = FALSE; - if ((ConfGetBool("threading.set-cpu-affinity", &threading_set_cpu_affinity)) == 0) { - threading_set_cpu_affinity = FALSE; + int affinity = 0; + if ((ConfGetBool("threading.set-cpu-affinity", &affinity)) == 0) { + threading_set_cpu_affinity = false; + } else { + threading_set_cpu_affinity = affinity == 1; } + /* try to get custom cpu mask value if needed */ - if (threading_set_cpu_affinity == TRUE) { + if (threading_set_cpu_affinity) { AffinitySetupLoadFromConfig(); } if ((ConfGetFloat("threading.detect-thread-ratio", &threading_detect_ratio)) != 1) { diff --git a/src/runmodes.h b/src/runmodes.h index 57b31b6d4054..668896dc17c5 100644 --- a/src/runmodes.h +++ b/src/runmodes.h @@ -100,7 +100,7 @@ bool IsRunModeSystem(enum RunModes run_mode_to_check); void RunModeEnablesBypassManager(void); int RunModeNeedsBypassManager(void); -extern int threading_set_cpu_affinity; +extern bool threading_set_cpu_affinity; extern float threading_detect_ratio; extern uint64_t threading_set_stack_size; diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 164825440f0c..2b8a4d079cef 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -779,7 +779,7 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream) if (use_raw) { uint64_t raw_progress = STREAM_RAW_PROGRESS(stream); - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { uint32_t chunk_size = (stream == &ssn->client) ? stream_config.reassembly_toserver_chunk_size : stream_config.reassembly_toclient_chunk_size; @@ -834,14 +834,14 @@ static inline uint64_t GetLeftEdge(Flow *f, TcpSession *ssn, TcpStream *stream) last_ack_abs += (stream->last_ack - stream->base_seq); } /* in IDS mode we shouldn't see the base_seq pass last_ack */ - DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && StreamTcpInlineMode() == FALSE && !f->ffr && + DEBUG_VALIDATE_BUG_ON(last_ack_abs < left_edge && !StreamTcpInlineMode() && !f->ffr && ssn->state < TCP_CLOSED); left_edge = MIN(left_edge, last_ack_abs); /* if we're told to look for overlaps with different data we should * consider data that is ack'd as well. Injected packets may have * been ack'd or injected packet may be too late. */ - if (StreamTcpInlineMode() == FALSE && check_overlap_different_data) { + if (!StreamTcpInlineMode() && check_overlap_different_data) { const uint32_t window = stream->window ? stream->window : 4096; if (window < left_edge) left_edge -= window; diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 737b222d53e2..06992da791a5 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -421,7 +421,7 @@ uint64_t StreamTcpGetAcked(const TcpStream *stream) uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof) { uint64_t right_edge = STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq; - if (!eof && StreamTcpInlineMode() == FALSE) { + if (!eof && !StreamTcpInlineMode()) { right_edge = MIN(GetAbsLastAck(stream), right_edge); } return right_edge; @@ -430,7 +430,7 @@ uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof) uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof) { uint64_t right_edge = StreamingBufferGetConsecutiveDataRightEdge(&stream->sb); - if (!eof && StreamTcpInlineMode() == FALSE) { + if (!eof && !StreamTcpInlineMode()) { right_edge = MIN(GetAbsLastAck(stream), right_edge); } return right_edge; @@ -496,7 +496,7 @@ static int StreamTcpReassemblyConfig(bool quiet) if (overlap_diff_data) { StreamTcpReassembleConfigEnableOverlapCheck(); } - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { StreamTcpReassembleConfigEnableOverlapCheck(); } @@ -1189,7 +1189,7 @@ static inline uint32_t AdjustToAcked(const Packet *p, uint32_t adjusted = data_len; /* get window of data that is acked */ - if (StreamTcpInlineMode() == FALSE) { + if (!StreamTcpInlineMode()) { SCLogDebug("ssn->state %s", StreamTcpStateAsString(ssn->state)); if (data_len == 0 || ((ssn->state < TCP_CLOSED || (ssn->state == TCP_CLOSED && @@ -1481,7 +1481,7 @@ bool StreamReassembleRawHasDataReady(TcpSession *ssn, Packet *p) STREAMTCP_STREAM_FLAG_DISABLE_RAW)) return false; - if (StreamTcpInlineMode() == FALSE) { + if (!StreamTcpInlineMode()) { const uint64_t segs_re_abs = STREAM_BASE_OFFSET(stream) + stream->segs_right_edge - stream->base_seq; if (STREAM_RAW_PROGRESS(stream) == segs_re_abs) { @@ -1860,7 +1860,7 @@ int StreamReassembleRaw(TcpSession *ssn, const Packet *p, uint64_t *progress_out, bool respect_inspect_depth) { /* handle inline separately as the logic is very different */ - if (StreamTcpInlineMode() == TRUE) { + if (StreamTcpInlineMode()) { return StreamReassembleRawInline(ssn, p, Callback, cb_data, progress_out); } diff --git a/src/stream-tcp.c b/src/stream-tcp.c index d76a0593a0d2..d41110aac5c7 100644 --- a/src/stream-tcp.c +++ b/src/stream-tcp.c @@ -6851,9 +6851,9 @@ int StreamTcpBypassEnabled(void) * \retval 0 no * \retval 1 yes */ -int StreamTcpInlineMode(void) +bool StreamTcpInlineMode(void) { - return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE) ? 1 : 0; + return (stream_config.flags & STREAMTCP_INIT_FLAG_INLINE); } diff --git a/src/stream-tcp.h b/src/stream-tcp.h index 324671245995..ff8a0998cb4e 100644 --- a/src/stream-tcp.h +++ b/src/stream-tcp.h @@ -191,7 +191,7 @@ void StreamTcpSessionCleanup(TcpSession *ssn); void StreamTcpStreamCleanup(TcpStream *stream); /* check if bypass is enabled */ int StreamTcpBypassEnabled(void); -int StreamTcpInlineMode(void); +bool StreamTcpInlineMode(void); int TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn); diff --git a/src/suricata-common.h b/src/suricata-common.h index fe8ec179dff3..4aad25a252f4 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -30,9 +30,6 @@ #define DBG_PERF #endif -#define TRUE 1 -#define FALSE 0 - #define _GNU_SOURCE #define __USE_GNU diff --git a/src/suricata.c b/src/suricata.c index 7f979a7fbfcc..fd069e6e5ddd 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -189,7 +189,7 @@ uint16_t max_pending_packets; int g_detect_disabled = 0; /** set caps or not */ -int sc_set_caps = FALSE; +bool sc_set_caps = false; bool g_system = false; @@ -1075,7 +1075,7 @@ static void SCInstanceInit(SCInstance *suri, const char *progname) memset(suri->pcap_dev, 0, sizeof(suri->pcap_dev)); suri->sig_file = NULL; - suri->sig_file_exclusive = FALSE; + suri->sig_file_exclusive = false; suri->pid_filename = NULL; suri->regex_arg = NULL; @@ -1084,8 +1084,8 @@ static void SCInstanceInit(SCInstance *suri, const char *progname) #ifndef OS_WIN32 suri->user_name = NULL; suri->group_name = NULL; - suri->do_setuid = FALSE; - suri->do_setgid = FALSE; + suri->do_setuid = false; + suri->do_setgid = false; #endif /* OS_WIN32 */ suri->userid = 0; suri->groupid = 0; @@ -1605,7 +1605,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) return TM_ECODE_FAILED; #else suri->user_name = optarg; - suri->do_setuid = TRUE; + suri->do_setuid = true; #endif /* HAVE_LIBCAP_NG */ } else if (strcmp((long_opts[option_index]).name, "group") == 0) { #ifndef HAVE_LIBCAP_NG @@ -1614,7 +1614,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) return TM_ECODE_FAILED; #else suri->group_name = optarg; - suri->do_setgid = TRUE; + suri->do_setgid = true; #endif /* HAVE_LIBCAP_NG */ } else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) { suri->run_mode = RUNMODE_ERF_FILE; @@ -1972,7 +1972,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri) return TM_ECODE_FAILED; } suri->sig_file = optarg; - suri->sig_file_exclusive = TRUE; + suri->sig_file_exclusive = true; break; case 'u': #ifdef UNITTESTS @@ -2142,25 +2142,25 @@ static int InitRunAs(SCInstance *suri) #ifndef OS_WIN32 /* Try to get user/group to run suricata as if command line as not decide of that */ - if (suri->do_setuid == FALSE && suri->do_setgid == FALSE) { + if (!suri->do_setuid && !suri->do_setgid) { const char *id; if (ConfGet("run-as.user", &id) == 1) { - suri->do_setuid = TRUE; + suri->do_setuid = true; suri->user_name = id; } if (ConfGet("run-as.group", &id) == 1) { - suri->do_setgid = TRUE; + suri->do_setgid = true; suri->group_name = id; } } /* Get the suricata user ID to given user ID */ - if (suri->do_setuid == TRUE) { + if (suri->do_setuid) { SCGetUserID(suri->user_name, suri->group_name, &suri->userid, &suri->groupid); - sc_set_caps = TRUE; - /* Get the suricata group ID to given group ID */ - } else if (suri->do_setgid == TRUE) { + sc_set_caps = true; + /* Get the suricata group ID to given group ID */ + } else if (suri->do_setgid) { SCGetGroupID(suri->group_name, &suri->groupid); - sc_set_caps = TRUE; + sc_set_caps = true; } #endif return TM_ECODE_OK; diff --git a/src/suricata.h b/src/suricata.h index 957134b92c06..9d275edc5dd0 100644 --- a/src/suricata.h +++ b/src/suricata.h @@ -126,7 +126,7 @@ typedef struct SCInstance_ { char pcap_dev[128]; char *sig_file; - int sig_file_exclusive; + bool sig_file_exclusive; char *pid_filename; char *regex_arg; @@ -135,8 +135,8 @@ typedef struct SCInstance_ { #ifndef OS_WIN32 const char *user_name; const char *group_name; - uint8_t do_setuid; - uint8_t do_setgid; + bool do_setuid; + bool do_setgid; #endif /* OS_WIN32 */ uint32_t userid; uint32_t groupid; diff --git a/src/util-debug.c b/src/util-debug.c index 80509ae7ca0b..c62a0104dda3 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -341,7 +341,7 @@ static const char *SCTransformModule(const char *module_name, int *dn_len) * * \retval 0 on success; else a negative value on error */ -static SCError SCLogMessageGetBuffer(SCTime_t tval, int color, SCLogOPType type, char *buffer, +static SCError SCLogMessageGetBuffer(SCTime_t tval, bool color, SCLogOPType type, char *buffer, size_t buffer_size, const char *log_format, const SCLogLevel log_level, const char *file, const unsigned int line, const char *function, const char *module, const char *message) { @@ -952,7 +952,7 @@ static inline SCLogOPIfaceCtx *SCLogInitConsoleOPIface(const char *log_format, #ifndef OS_WIN32 if (isatty(fileno(stdout)) && isatty(fileno(stderr))) { - iface_ctx->use_color = TRUE; + iface_ctx->use_color = true; } #endif diff --git a/src/util-debug.h b/src/util-debug.h index 2a0864cdd83a..296cf896519c 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -115,7 +115,7 @@ typedef struct SCLogOPBuffer_ { typedef struct SCLogOPIfaceCtx_ { SCLogOPIface iface; - int16_t use_color; + bool use_color; SCLogOPType type; /* the output file to be used if the interface is SC_LOG_IFACE_FILE */ diff --git a/src/util-landlock.c b/src/util-landlock.c index d14e1bed0aeb..258993c30d5c 100644 --- a/src/util-landlock.c +++ b/src/util-landlock.c @@ -244,7 +244,7 @@ void LandlockSandboxing(SCInstance *suri) LandlockSandboxingWritePath(ruleset, LOCAL_STATE_DIR "/run/suricata/"); } } - if (suri->sig_file_exclusive == FALSE) { + if (!suri->sig_file_exclusive) { const char *rule_path; if (ConfGet("default-rule-path", &rule_path) == 1 && rule_path) { LandlockSandboxingReadPath(ruleset, rule_path); diff --git a/src/util-privs.c b/src/util-privs.c index 8210cc8065d9..3a1ea485159a 100644 --- a/src/util-privs.c +++ b/src/util-privs.c @@ -44,7 +44,7 @@ #include "runmodes.h" /** flag indicating if we'll be using caps */ -extern int sc_set_caps; +extern bool sc_set_caps; /** our current runmode */ extern int run_mode; @@ -54,7 +54,7 @@ extern int run_mode; */ void SCDropMainThreadCaps(uint32_t userid, uint32_t groupid) { - if (sc_set_caps == FALSE) + if (!sc_set_caps) return; capng_clear(CAPNG_SELECT_BOTH);