Jakub Filak <[email protected]> writes:
> Signed-off-by: Jakub Filak <[email protected]>
> ---
> src/lib/run_event.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/run_event.c b/src/lib/run_event.c
> index 151b8be..2f9ec92 100644
> --- a/src/lib/run_event.c
> +++ b/src/lib/run_event.c
> @@ -439,6 +439,11 @@ int run_event_on_dir_name(struct run_event_state *state,
> const char *dump_dir_name,
> const char *event
> ) {
> + static const size_t alert_prefix_len = sizeof(REPORT_PREFIX_ALERT) - 1;
> + static const size_t ask_prefix_len = sizeof(REPORT_PREFIX_ASK) - 1;
> + static const size_t ask_yes_no_prefix_len =
> sizeof(REPORT_PREFIX_ASK_YES_NO) - 1;
> + static const size_t ask_password_prefix_len =
> sizeof(REPORT_PREFIX_ASK_PASSWORD) - 1;
> +
> prepare_commands(state, dump_dir_name, event);
>
> /* Execute every command in shell */
> @@ -453,11 +458,6 @@ int run_event_on_dir_name(struct run_event_state *state,
> char *buf;
> char *msg;
>
> - int alert_prefix_len = strlen(REPORT_PREFIX_ALERT);
> - int ask_prefix_len = strlen(REPORT_PREFIX_ASK);
> - int ask_yes_no_prefix_len = strlen(REPORT_PREFIX_ASK_YES_NO);
> - int ask_password_prefix_len = strlen(REPORT_PREFIX_ASK_PASSWORD);
> -
> while ((buf = xmalloc_fgetline(fp)) != NULL)
> {
> msg = buf;
I still don't get it, why are you/we using strncmp(var, "foo",
sizeof("foo") - 1) for prefix looking. there is way faster function
called _prefixcmp()_
--
Nikola