Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/modules/lua Fix LIST operations, found by strictly-align...



details:   https://anonhg.NetBSD.org/src/rev/988858d97546
branches:  trunk
changeset: 1022844:988858d97546
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Aug 08 22:26:32 2021 +0000

description:
Fix LIST operations, found by strictly-aligned CPUs, i.e., ARMv5 and IBM403:
- Initialize LIST_HEAD.
- Use LIST_FOREACH_SAFE() where necessary.

diffstat:

 sys/modules/lua/lua.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (40 lines):

diff -r 057d07a0b26d -r 988858d97546 sys/modules/lua/lua.c
--- a/sys/modules/lua/lua.c     Sun Aug 08 21:50:10 2021 +0000
+++ b/sys/modules/lua/lua.c     Sun Aug 08 22:26:32 2021 +0000
@@ -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@localhost>.
@@ -74,8 +74,10 @@
 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 @@
 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 @@
        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)



Home | Main Index | Thread Index | Old Index