From 75b133926fd02ff937c8bd86534c7526bed003d2 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Fri, 27 Mar 2020 20:12:06 -0700 Subject: [PATCH] AP_Scripting: Cleanups to remove false posive warnings --- libraries/AP_Scripting/lua/src/lua.c | 2 ++ libraries/AP_Scripting/lua_repl.cpp | 8 ++------ libraries/AP_Scripting/lua_scripts.cpp | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/AP_Scripting/lua/src/lua.c b/libraries/AP_Scripting/lua/src/lua.c index ca5b298523..e85b964f51 100644 --- a/libraries/AP_Scripting/lua/src/lua.c +++ b/libraries/AP_Scripting/lua/src/lua.c @@ -1,3 +1,4 @@ +#if 0 /* ** $Id: lua.c,v 1.230.1.1 2017/04/19 17:29:57 roberto Exp $ ** Lua stand-alone interpreter @@ -610,3 +611,4 @@ int main (int argc, char **argv) { return (result && status == LUA_OK) ? EXIT_SUCCESS : EXIT_FAILURE; } +#endif diff --git a/libraries/AP_Scripting/lua_repl.cpp b/libraries/AP_Scripting/lua_repl.cpp index 567365734d..fc2b5b8cf0 100644 --- a/libraries/AP_Scripting/lua_repl.cpp +++ b/libraries/AP_Scripting/lua_repl.cpp @@ -98,7 +98,6 @@ int lua_scripts::incomplete(lua_State *L, int status) { */ int lua_scripts::pushline(lua_State *L, int firstline) { char buffer[LUA_MAXINPUT + 1] = {}; - ssize_t read_bytes; size_t l = 0; // send prompt to the user @@ -109,15 +108,12 @@ int lua_scripts::pushline(lua_State *L, int firstline) { int input_fd = AP::FS().open(REPL_IN, O_RDONLY); if (input_fd != -1) { AP::FS().lseek(input_fd, terminal.input_offset, SEEK_SET); - read_bytes = AP::FS().read(input_fd, buffer, ARRAY_SIZE(buffer) - 1); + ssize_t read_bytes = AP::FS().read(input_fd, buffer, ARRAY_SIZE(buffer) - 1); AP::FS().close(input_fd); if (read_bytes > 0) { // locate the first newline char * newline_chr = strchr(buffer, '\n'); - if (newline_chr == NULL) { - // we don't have something that looks like a newline, just keep reading till it's longer - read_bytes = 0; - } else { + if (newline_chr != NULL) { newline_chr[0] = '\0'; // only advance to the newline l = strlen(buffer); diff --git a/libraries/AP_Scripting/lua_scripts.cpp b/libraries/AP_Scripting/lua_scripts.cpp index ae44cf0285..3d7a326895 100644 --- a/libraries/AP_Scripting/lua_scripts.cpp +++ b/libraries/AP_Scripting/lua_scripts.cpp @@ -374,7 +374,9 @@ void lua_scripts::run(void) { load_all_scripts_in_dir(L, SCRIPTING_DIRECTORY); load_all_scripts_in_dir(L, "@ROMFS/scripts"); +#ifndef __clang_analyzer__ succeeded_initial_load = true; +#endif // __clang_analyzer__ while (AP_Scripting::get_singleton()->enabled()) { // handle terminal data if we have any