From: Patrick Donnelly Date: Sun, 14 Feb 2016 00:59:09 +0000 (-0500) Subject: lua: use simpler lua_next traversal structure X-Git-Tag: v11.1.0~282^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0f334f2870a87bda29e009ef90d7b9174e46a019;p=ceph.git lua: use simpler lua_next traversal structure Signed-off-by: Patrick Donnelly --- diff --git a/src/cls/lua/cls_lua.cc b/src/cls/lua/cls_lua.cc index 39506fa9d33b..811c1771dade 100644 --- a/src/cls/lua/cls_lua.cc +++ b/src/cls/lua/cls_lua.cc @@ -509,8 +509,7 @@ static int clslua_map_set_vals(lua_State *L) map kvpairs; - lua_pushnil(L); - while (lua_next(L, 1) != 0) { + for (lua_pushnil(L); lua_next(L, 1); lua_pop(L, 1)) { /* * In the case of a numeric key a copy is made on the stack because * converting to a string would otherwise manipulate the original key and @@ -553,8 +552,6 @@ static int clslua_map_set_vals(lua_State *L) } kvpairs[key] = val; - - lua_pop(L, 1); } int ret = cls_cxx_map_set_vals(hctx, &kvpairs); diff --git a/src/mds/Mantle.cc b/src/mds/Mantle.cc index e9a65ef1a0cb..d0520c27014b 100644 --- a/src/mds/Mantle.cc +++ b/src/mds/Mantle.cc @@ -143,15 +143,13 @@ int Mantle::balance(const string &script, /* fill in return value */ mds_rank_t it = mds_rank_t(0); - lua_pushnil(L); - while (lua_next(L, -2) != 0) { + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { if (!lua_isnumber(L, -1)) { dout(0) << "WARNING: mantle script returned a malformed response" << dendl; lua_close(L); return -EINVAL; } my_targets[it] = (lua_tonumber(L, -1)); - lua_pop(L, 1); it++; }