Re: [PATCH v2 4/7] tracing: Add synthetic event error logging
From: Steven Rostedt
Date: Mon Oct 12 2020 - 17:43:00 EST
On Mon, 12 Oct 2020 15:18:06 -0500
Tom Zanussi <zanussi@xxxxxxxxxx> wrote:
> +static char last_cmd[MAX_FILTER_STR_VAL];
> +
> +static int errpos(const char *str)
> +{
> + return err_pos(last_cmd, str);
> +}
> +
> +static void last_cmd_set(char *str)
> +{
> + if (!str)
> + return;
> +
> + strncat(last_cmd, str, MAX_FILTER_STR_VAL - 1);
If I understand strncat() correctly, it will add 'n' + 1 bytes from str
to last_cmd. That is, I think you want:
strncat(last_cmd, str, MAX_FILTER_STR_VAL - (strlen(last_cmd) + 1));
-- Steve
> +}
> +
> +static void synth_err(u8 err_type, u8 err_pos)
> +{
> + tracing_log_err(NULL, "synthetic_events", last_cmd, err_text,
> + err_type, err_pos);
> +}
> +
> +static void synth_err_clear(void)
> +{
> + last_cmd[0] = '\0';
> +}
> +