From fd9f38ea42b04d23203c1d407d8c6f19d673264b Mon Sep 17 00:00:00 2001 From: dacctal Date: Fri, 26 Jun 2026 07:25:38 +0000 Subject: fixed false positives on lua return values --- src/create_pkg.c | 2 +- src/fetch_git.c | 2 +- src/fetch_src.c | 1 + src/lua_state.c | 18 +++++++++--------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/create_pkg.c b/src/create_pkg.c index 0137dd7..cb35ad0 100644 --- a/src/create_pkg.c +++ b/src/create_pkg.c @@ -87,7 +87,7 @@ Pkg create_pkg(const char *arg) { bool is_in_repos = false; for (size_t i = 0; i < cached_repos_count; i++) { - if (strcmp(arg, cached_repos[i].source_key) == 0) { + if (strcmp(new_arg, cached_repos[i].source_key) == 0) { is_in_repos = true; break; } diff --git a/src/fetch_git.c b/src/fetch_git.c index d7d1741..f47b881 100644 --- a/src/fetch_git.c +++ b/src/fetch_git.c @@ -18,7 +18,7 @@ int fetch_git(Pkg pkg) { close(nullfd); } } - const char *argv[8]; + const char *argv[10]; int i = 0; argv[i++] = "git"; argv[i++] = "-c"; diff --git a/src/fetch_src.c b/src/fetch_src.c index 55ce135..8646b1d 100644 --- a/src/fetch_src.c +++ b/src/fetch_src.c @@ -29,6 +29,7 @@ void fetch_src(Pkg pkg) { if (file_exists(pkg.src)) { if (is_verbose) printf("%s %s already exists. deleting...\n", print_pkgit, pkg.src); + chdir(".."); nftw(pkg.src, remove_tree, 64, FTW_DEPTH | FTW_PHYS); } if (strcmp(pkg.url, "") == 0) { diff --git a/src/lua_state.c b/src/lua_state.c index 9751780..ed3f1cc 100644 --- a/src/lua_state.c +++ b/src/lua_state.c @@ -177,7 +177,7 @@ bool target_loop_build( lua_pop(L, 3); return false; } - if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) if (is_verbose) { + if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) { printf( "%s %s: 'targets.%s.build' failed: %s\n", print_error, lua_file, target, lua_tostring(L, -1) @@ -210,10 +210,10 @@ bool target_loop_install(lua_State *L, const char* lua_file, const char *target) "%s %s: 'targets.%s.pre_install' function borked: %s\n", print_warning, lua_file, target, lua_tostring(L, -1) ); - if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) if (is_verbose) { + if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) { printf( - "%s %s: 'targets.%s.pre_install' failed: %s\n", - print_error, lua_file, target, lua_tostring(L, -1) + "%s %s: 'targets.%s.pre_install' failed: %d\n", + print_error, lua_file, target, (int)lua_tonumber(L, -1) ); return false; } @@ -236,10 +236,10 @@ bool target_loop_install(lua_State *L, const char* lua_file, const char *target) lua_pop(L, 1); return false; } - if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) if (is_verbose) { + if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) { printf( - "%s %s: 'targets.%s.install' failed: %s\n", - print_error, lua_file, target, lua_tostring(L, -1) + "%s %s: 'targets.%s.install' failed: %d\n", + print_error, lua_file, target, (int)lua_tonumber(L, -1) ); lua_pop(L, 1); return false; @@ -256,7 +256,7 @@ bool target_loop_install(lua_State *L, const char* lua_file, const char *target) "%s %s: 'targets.%s.post_install' function borked: %s\n", print_warning, lua_file, target, lua_tostring(L, -1) ); - if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) if (is_verbose) { + if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) { printf( "%s %s: 'targets.%s.post_install' failed: %s\n", print_error, lua_file, target, lua_tostring(L, -1) @@ -294,7 +294,7 @@ bool target_loop_uninstall(lua_State *L, const char *lua_file, const char *targe lua_pop(L, 1); return false; } - if (!lua_isnumber(L, -1) || lua_tonumber(L, -1) != 0) if (is_verbose) { + if ((int)lua_tonumber(L, -1) != 0) if (is_verbose) { printf( "%s %s: 'targets.%s.uninstall' failed: %s\n", print_error, lua_file, target, lua_tostring(L, -1) -- cgit v1.2.3