summaryrefslogtreecommitdiff
path: root/sys/modules/lua
diff options
context:
space:
mode:
authorrin <rin@NetBSD.org>2021-08-08 22:26:32 +0000
committerrin <rin@NetBSD.org>2021-08-08 22:26:32 +0000
commitac361a949f5e7e663274d24c8689043a338bfd70 (patch)
treef8811ae016439c9aa262b6b5b96a6cd28cd16a46 /sys/modules/lua
parentb2c6bd46514889c267795e8e9c3169572740e641 (diff)
Fix LIST operations, found by strictly-aligned CPUs, i.e., ARMv5 and IBM403:
- Initialize LIST_HEAD. - Use LIST_FOREACH_SAFE() where necessary.
Diffstat (limited to 'sys/modules/lua')
-rw-r--r--sys/modules/lua/lua.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/modules/lua/lua.c b/sys/modules/lua/lua.c
index 00f966b8036..bfe548343e6 100644
--- a/sys/modules/lua/lua.c
+++ b/sys/modules/lua/lua.c
@@ -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 <mbalmer@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 char *desc, int ipl)
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)