Skip to content

Commit 3e47dc3

Browse files
committed
luzer: fix an error due to unused jit_status
The C compiler produce an error because variable `jit_status` and the related code are unused when PUC Rio Lua library is used. The patch declared variable conditionally to fix the error.
1 parent ac8432c commit 3e47dc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

luzer/luzer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
#define DEBUG_HOOK_FUNC "luzer_custom_hook"
3838

3939
static lua_State *LL;
40+
#if defined(LUA_HAS_JIT) && defined(LUAJIT_FRIENDLY_MODE)
4041
static int jit_status = 0;
42+
#endif /* LUA_HAS_JIT && LUAJIT_FRIENDLY_MODE */
4143

4244
int internal_hook_disabled = 0;
4345

@@ -208,10 +210,10 @@ sig_handler(int sig)
208210
}
209211

210212
/* Returns the current status of the JIT compiler. */
213+
#if defined(LUA_HAS_JIT) && defined(LUAJIT_FRIENDLY_MODE)
211214
NO_SANITIZE static int
212215
luajit_has_enabled_jit(lua_State *L)
213216
{
214-
#if defined(LUA_HAS_JIT)
215217
lua_getglobal(L, "jit");
216218
lua_getfield(L, -1, "status");
217219
/*
@@ -223,10 +225,8 @@ luajit_has_enabled_jit(lua_State *L)
223225
*/
224226
lua_pcall(L, 0, 1, 0);
225227
return lua_toboolean(L, -1);
226-
#else
227-
return 0;
228-
#endif
229228
}
229+
#endif /* LUA_HAS_JIT && LUAJIT_FRIENDLY_MODE */
230230

231231
NO_SANITIZE int
232232
luaL_mutate(lua_State *L)
@@ -524,7 +524,9 @@ luaL_fuzz(lua_State *L)
524524
}
525525
lua_pop(L, -1);
526526

527+
#if defined(LUA_HAS_JIT) && defined(LUAJIT_FRIENDLY_MODE)
527528
jit_status = luajit_has_enabled_jit(L);
529+
#endif
528530
set_global_lua_state(L);
529531
int rc = LLVMFuzzerRunDriver(&argc, &argv, &TestOneInput);
530532

0 commit comments

Comments
 (0)