[Lldb-commits] [PATCH] D90556: [LLDB][NFC] treat Lua error codes in a more explicit manner

Pedro Tammela via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Nov 1 08:26:28 PST 2020


tammela created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
tammela requested review of this revision.
Herald added a subscriber: JDevlieghere.

This patch is a minor suggestion to not rely on the fact
that the `LUA_OK` macro is 0.

This assumption could change in future versions of the C API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90556

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -18,7 +18,7 @@
   int error =
       luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
       lua_pcall(m_lua_state, 0, 0, 0);
-  if (!error)
+  if (error == LUA_OK)
     return llvm::Error::success();
 
   llvm::Error e = llvm::make_error<llvm::StringError>(
@@ -44,7 +44,7 @@
 
   int error = luaL_loadfile(m_lua_state, filename.data()) ||
               lua_pcall(m_lua_state, 0, 1, 0);
-  if (error) {
+  if (error != LUA_OK) {
     llvm::Error e = llvm::make_error<llvm::StringError>(
         llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)),
         llvm::inconvertibleErrorCode());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90556.302149.patch
Type: text/x-patch
Size: 854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201101/d416bc1b/attachment.bin>


More information about the lldb-commits mailing list