From 32533b4b6ea73b69f654ae2d337b3262da36830a Mon Sep 17 00:00:00 2001 From: cmss_dx Date: Wed, 23 Nov 2022 06:23:16 +0000 Subject: [PATCH 07/29] tcg/tci: fix logic error when registering helpers via FFI mainline inclusion from mainline-v7.2.0-rc1 commit 9dd1d56e570e5119fef2b28fda811d6891e597a8 category: bugfix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -------------------------------- 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. Fixes: 22f1557 ("tcg: Build ffi data structures for helpers") Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Icenowy Zheng Message-Id: <20221028072145.1593205-1-uwu@icenowy.me> [rth: Move declaration of j to the for loop itself] Signed-off-by: Richard Henderson Signed-off-by: cmss_dx --- tcg/tcg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 934aa8510b..635555001b 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -632,9 +632,9 @@ static void tcg_context_init(unsigned max_cpus) if (nargs != 0) { 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 (int j = 0; j < nargs; ++j) { + int typecode = extract32(typemask, (j + 1) * 3, 3); + ca->args[j] = typecode_to_ffi[typecode]; } } -- 2.27.0