commandline: output cleanups

pull/8304/head
Victor Julien 4 years ago
parent da5fa24ab2
commit fa7760aa67

@ -271,7 +271,7 @@ static void SignalHandlerUnexpected(int sig_num, siginfo_t *info, void *context)
signal(SIGSEGV, SIG_DFL); signal(SIGSEGV, SIG_DFL);
int r; int r;
if ((r = unw_init_local(&cursor, (unw_context_t *)(context)) != 0)) { if ((r = unw_init_local(&cursor, (unw_context_t *)(context)) != 0)) {
fprintf(stderr, "unable to obtain stack trace: unw_init_local: %s\n", unw_strerror(r)); SCLogError("unable to obtain stack trace: unw_init_local: %s", unw_strerror(r));
goto terminate; goto terminate;
} }
@ -564,9 +564,8 @@ static void SetBpfStringFromFile(char *filename)
} }
if (strlen(bpf_filter) > 0) { if (strlen(bpf_filter) > 0) {
if (ConfSetFinal("bpf-filter", bpf_filter) != 1) { if (ConfSetFinal("bpf-filter", bpf_filter) != 1) {
SCLogError("ERROR: Failed to set bpf filter!");
SCFree(bpf_filter); SCFree(bpf_filter);
exit(EXIT_FAILURE); FatalError("failed to set bpf filter");
} }
} }
} }
@ -1508,7 +1507,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
EngineModeSetIPS(); EngineModeSetIPS();
} else if (strcmp((long_opts[option_index]).name, "init-errors-fatal") == 0) { } else if (strcmp((long_opts[option_index]).name, "init-errors-fatal") == 0) {
if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) { if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) {
fprintf(stderr, "ERROR: Failed to set engine init-failure-fatal.\n"); SCLogError("failed to set engine init-failure-fatal");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
#ifdef BUILD_UNIX_SOCKET #ifdef BUILD_UNIX_SOCKET
@ -1517,7 +1516,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
suri->run_mode = RUNMODE_UNIX_SOCKET; suri->run_mode = RUNMODE_UNIX_SOCKET;
if (optarg) { if (optarg) {
if (ConfSetFinal("unix-command.filename", optarg) != 1) { if (ConfSetFinal("unix-command.filename", optarg) != 1) {
fprintf(stderr, "ERROR: Failed to set unix-command.filename.\n"); SCLogError("failed to set unix-command.filename");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
@ -1537,7 +1536,8 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
#ifdef UNITTESTS #ifdef UNITTESTS
suri->run_mode = RUNMODE_LIST_UNITTEST; suri->run_mode = RUNMODE_LIST_UNITTEST;
#else #else
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n"); SCLogError("unit tests not enabled. Make sure to pass --enable-unittests to "
"configure when building");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
#endif /* UNITTESTS */ #endif /* UNITTESTS */
} else if (strcmp((long_opts[option_index]).name, "list-runmodes") == 0) { } else if (strcmp((long_opts[option_index]).name, "list-runmodes") == 0) {
@ -1583,7 +1583,8 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
#ifdef UNITTESTS #ifdef UNITTESTS
unittests_fatal = 1; unittests_fatal = 1;
#else #else
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n"); SCLogError("unit tests not enabled. Make sure to pass --enable-unittests to "
"configure when building");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
#endif /* UNITTESTS */ #endif /* UNITTESTS */
} else if (strcmp((long_opts[option_index]).name, "user") == 0) { } else if (strcmp((long_opts[option_index]).name, "user") == 0) {
@ -1607,7 +1608,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
} else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) { } else if (strcmp((long_opts[option_index]).name, "erf-in") == 0) {
suri->run_mode = RUNMODE_ERF_FILE; suri->run_mode = RUNMODE_ERF_FILE;
if (ConfSetFinal("erf-file.file", optarg) != 1) { if (ConfSetFinal("erf-file.file", optarg) != 1) {
fprintf(stderr, "ERROR: Failed to set erf-file.file\n"); SCLogError("failed to set erf-file.file");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
} else if (strcmp((long_opts[option_index]).name, "dag") == 0) { } else if (strcmp((long_opts[option_index]).name, "dag") == 0) {
@ -1709,9 +1710,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
FatalError("Invalid argument for --set, must be key=val."); FatalError("Invalid argument for --set, must be key=val.");
} }
if (!ConfSetFromString(optarg, 1)) { if (!ConfSetFromString(optarg, 1)) {
fprintf(stderr, "Failed to set configuration value %s.", FatalError("failed to set configuration value %s", optarg);
optarg);
exit(EXIT_FAILURE);
} }
} }
} }
@ -1773,7 +1772,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
case 'T': case 'T':
conf_test = 1; conf_test = 1;
if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) { if (ConfSetFinal("engine.init-failure-fatal", "1") != 1) {
fprintf(stderr, "ERROR: Failed to set engine init-failure-fatal.\n"); SCLogError("failed to set engine init-failure-fatal");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
break; break;
@ -1953,7 +1952,8 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
} }
#else #else
fprintf(stderr, "ERROR: Unit tests not enabled. Make sure to pass --enable-unittests to configure when building.\n"); SCLogError("unit tests not enabled. Make sure to pass --enable-unittests to configure "
"when building.");
return TM_ECODE_FAILED; return TM_ECODE_FAILED;
#endif /* UNITTESTS */ #endif /* UNITTESTS */
break; break;

Loading…
Cancel
Save