在 2022-10-28星期五的 10:13 +0100,Alex Bennée写道:
> 
> Icenowy Zheng <u...@icenowy.me> writes:
> 
> > When registering helpers via FFI for TCI, the inner loop that
> > iterates
> > parameters of the helper reuses (and thus pollutes) the same
> > variable
> > used by the outer loop that iterates all helpers, thus made some
> > helpers
> > unregistered.
> > 
> > Fix this logic error by using a dedicated temporary variable for
> > the
> > inner loop.
> > 
> > Signed-off-by: Icenowy Zheng <u...@icenowy.me>
> > ---
> >  tcg/tcg.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tcg/tcg.c b/tcg/tcg.c
> > index 612a12f58f..adfaf61a32 100644
> > --- a/tcg/tcg.c
> > +++ b/tcg/tcg.c
> > @@ -619,6 +619,7 @@ static void tcg_context_init(unsigned max_cpus)
> >          gpointer hash = (gpointer)(uintptr_t)typemask;
> >          ffi_status status;
> >          int nargs;
> > +        int j;
> 
> You could tuck this variable definition...
> 
> 
> >  
> >          if (g_hash_table_lookup(ffi_table, hash)) {
> >              continue;
> > @@ -634,9 +635,9 @@ static void tcg_context_init(unsigned max_cpus)
> >  
> >          if (nargs != 0) {
> 
> here to keep things more local.

Oops I was trying to find the nearest existing variable definition when
writing this, and forget this is a block's start.

Thanks for this tip
Icenowy Zheng

> 
> >              ca->cif.arg_types = ca->args;
> > -            for (i = 0; i < nargs; ++i) {
> > -                int typecode = extract32(typemask, (i + 1) * 3,
> > 3);
> > -                ca->args[i] = typecode_to_ffi[typecode];
> > +            for (j = 0; j < nargs; ++j) {
> > +                int typecode = extract32(typemask, (j + 1) * 3,
> > 3);
> > +                ca->args[j] = typecode_to_ffi[typecode];
> >              }
> >          }
> 
> Otherwise:
> 
> Reviewed-by: Alex Bennée <alex.ben...@linaro.org>
> 

Reply via email to