profiling/rules: simplify return code handling

pull/8879/head
Victor Julien 3 years ago
parent 835eaf7ccd
commit 2423b2a483

@ -798,12 +798,7 @@ static TmEcode UnixManagerRulesetProfileCommand(json_t *cmd, json_t *server_msg,
static TmEcode UnixManagerRulesetProfileStartCommand(json_t *cmd, json_t *server_msg, void *data)
{
SCEnter();
int ret = SCProfileRuleStartCollection();
if (ret != TM_ECODE_OK) {
json_object_set_new(server_msg, "message", json_string("NOK"));
SCReturnInt(TM_ECODE_FAILED);
}
SCProfileRuleStartCollection();
json_object_set_new(server_msg, "message", json_string("OK"));
SCReturnInt(TM_ECODE_OK);
}
@ -811,16 +806,10 @@ static TmEcode UnixManagerRulesetProfileStartCommand(json_t *cmd, json_t *server
static TmEcode UnixManagerRulesetProfileStopCommand(json_t *cmd, json_t *server_msg, void *data)
{
SCEnter();
int ret = SCProfileRuleStopCollection();
if (ret != TM_ECODE_OK) {
json_object_set_new(server_msg, "message", json_string("NOK"));
SCReturnInt(TM_ECODE_FAILED);
}
SCProfileRuleStopCollection();
json_object_set_new(server_msg, "message", json_string("OK"));
SCReturnInt(TM_ECODE_OK);
}
#endif
static TmEcode UnixManagerShowFailedRules(json_t *cmd,

@ -1405,14 +1405,12 @@ SCProfilingRegisterTests(void)
#endif /* UNITTESTS */
}
int SCProfileRuleStartCollection(void)
void SCProfileRuleStartCollection(void)
{
SCReturnInt(TM_ECODE_OK);
}
int SCProfileRuleStopCollection(void)
void SCProfileRuleStopCollection(void)
{
SCReturnInt(TM_ECODE_OK);
}
#elif PROFILE_RULES
@ -1466,16 +1464,14 @@ int SCProfileRuleStart(Packet *p)
return 0;
}
int SCProfileRuleStartCollection(void)
void SCProfileRuleStartCollection(void)
{
SC_ATOMIC_SET(profiling_rules_active, true);
SCReturnInt(TM_ECODE_OK);
}
int SCProfileRuleStopCollection(void)
void SCProfileRuleStopCollection(void)
{
SC_ATOMIC_SET(profiling_rules_active, false);
SCReturnInt(TM_ECODE_OK);
}
#endif /* PROFILING */

@ -401,8 +401,8 @@ void SCProfilingRuleThreadSetup(struct SCProfileDetectCtx_ *, DetectEngineThread
void SCProfilingRuleThreadCleanup(DetectEngineThreadCtx *);
int SCProfileRuleStart(Packet *p);
json_t *SCProfileRuleTriggerDump(DetectEngineCtx *de_ctx);
int SCProfileRuleStartCollection(void);
int SCProfileRuleStopCollection(void);
void SCProfileRuleStartCollection(void);
void SCProfileRuleStopCollection(void);
void SCProfilingRuleThreatAggregate(DetectEngineThreadCtx *det_ctx);
#define RULE_PROFILING_START(p) \

Loading…
Cancel
Save