[LTP] [PATCH v3 1/2] lib: Add generic boolean expression parser and eval
Cyril Hrubis
chrubis@suse.cz
Tue Nov 3 14:10:43 CET 2020
Hi!
> > +struct tst_expr {
> > + struct tst_expr_tok *expr;
>
> Maybe call this 'first' or 'head'?
>
> > + struct tst_expr_tok *buf;
>
> I suppose that buf could be a trailing array saving a call to malloc and
> free :-)
Good point I do not know how I missed the simplest solution here.
> > + if (!check_two(expr->buf[cnt-1].op)) {
> > + expr->buf[cnt-1].priv = "Unfinished expression";
> > + goto err;
> > + }
>
> This looks a bit odd as it is the only place you use buf like this. Why
> not only use buf until setting expr=out[0] (and only set buf=tok
> initially) or only use expr until free(expr->buf) and/or do --i and use
> that?
I guess that makes sense. I will changed that anyways if I convert the
structure to a trailing array.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list