Author: Pedro Tammela
Date: 2020-11-03T09:39:47Z
New Revision: 4b9fa3b705c8280e71908f4cc8c115320ef48316

URL: 
https://github.com/llvm/llvm-project/commit/4b9fa3b705c8280e71908f4cc8c115320ef48316
DIFF: 
https://github.com/llvm/llvm-project/commit/4b9fa3b705c8280e71908f4cc8c115320ef48316.diff

LOG: [LLDB][NFC] treat Lua error codes in a more explicit manner

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.

Differential Revision: https://reviews.llvm.org/D90556

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
index acd6128d84c5..2db44f2d29d0 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -18,7 +18,7 @@ llvm::Error Lua::Run(llvm::StringRef buffer) {
   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 @@ llvm::Error Lua::LoadModule(llvm::StringRef filename) {
 
   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());


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to