Re: [PATCH v5 15/37] tracing: Add variable support to hist triggers

From: Steven Rostedt
Date: Fri Nov 10 2017 - 08:24:23 EST


On Fri, 10 Nov 2017 16:28:41 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:

> > + hist_data->attrs->var_defs.expr[n_vars++] = s;
> > +
> > + hist_data->attrs->var_defs.n_vars = n_vars;
> > +
> > + if (n_vars == TRACING_MAP_VARS_MAX)
> > + goto free;
>
> This will silently discard all variables. Why not returning an error?
> Also I think it should be moved to the beginning of this block..

Right, because the check here is already too late. Usually you check
the count before doing the assignment.


if (n_vars == TRACING_MAP_VARS_MAX)
goto free;

hist_data->attrs->var_defs.expr[n_vars++] = s;

Because it is OK for n_vars to equal TRACING_MAP_VARS_MAX, but not OK
to be more.

-- Steve