Module Name: src Committed By: rin Date: Sun Aug 8 22:26:32 UTC 2021
Modified Files: src/sys/modules/lua: lua.c Log Message: Fix LIST operations, found by strictly-aligned CPUs, i.e., ARMv5 and IBM403: - Initialize LIST_HEAD. - Use LIST_FOREACH_SAFE() where necessary. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/modules/lua/lua.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/modules/lua/lua.c diff -u src/sys/modules/lua/lua.c:1.26 src/sys/modules/lua/lua.c:1.27 --- src/sys/modules/lua/lua.c:1.26 Sat Aug 7 04:19:31 2021 +++ src/sys/modules/lua/lua.c Sun Aug 8 22:26:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lua.c,v 1.26 2021/08/07 04:19:31 rin Exp $ */ +/* $NetBSD: lua.c,v 1.27 2021/08/08 22:26:32 rin Exp $ */ /* * Copyright (c) 2011 - 2017 by Marc Balmer <mbal...@netbsd.org>. @@ -74,8 +74,10 @@ static bool lua_bytecode_on = false; static int lua_verbose; static int lua_max_instr; -static LIST_HEAD(, lua_state) lua_states; -static LIST_HEAD(, lua_module) lua_modules; +static LIST_HEAD(, lua_state) lua_states = + LIST_HEAD_INITIALIZER(lua_states); +static LIST_HEAD(, lua_module) lua_modules = + LIST_HEAD_INITIALIZER(lua_modules); static int lua_match(device_t, cfdata_t, void *); static void lua_attach(device_t, device_t, void *); @@ -723,7 +725,7 @@ kluaL_newstate(const char *name, const c void klua_close(klua_State *K) { - struct lua_state *s; + struct lua_state *s, *ns; struct lua_softc *sc; struct lua_module *m; int error = 0; @@ -747,7 +749,7 @@ klua_close(klua_State *K) if (error) return; /* Nothing we can do... */ - LIST_FOREACH(s, &lua_states, lua_next) + LIST_FOREACH_SAFE(s, &lua_states, lua_next, ns) if (s->K == K) { LIST_REMOVE(s, lua_next); LIST_FOREACH(m, &s->lua_modules, mod_next)