diff --git a/src/api/api.c b/src/api/api.c index 13b96eb6a..072f8014a 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -205,7 +205,8 @@ int luax_typeerror(lua_State* L, int index, const char* expected) { name = luaL_typename(L, index); } const char* message = lua_pushfstring(L, "%s expected, got %s", expected, name); - return luaL_argerror(L, index, message); + luaL_argerror(L, index, message); + return 0; } // Registers the userdata on the top of the stack in the registry. @@ -273,10 +274,12 @@ int _luax_checkenum(lua_State* L, int index, const StringEntry* map, const char* } if (index > 0) { - return luaL_argerror(L, index, lua_pushfstring(L, "invalid %s '%s'", label, string)); + luaL_argerror(L, index, lua_pushfstring(L, "invalid %s '%s'", label, string)); } else { - return luaL_error(L, "invalid %s '%s'", label, string); + luaL_error(L, "invalid %s '%s'", label, string); } + + return 0; } void luax_registerloader(lua_State* L, lua_CFunction loader, int index) { @@ -604,8 +607,9 @@ int luax_readmesh(lua_State* L, int index, float** vertices, uint32_t* vertexCou return index + 1; } - return luaL_argerror(L, index, "table, ModelData, Model, or Mesh expected"); + luaL_argerror(L, index, "table, ModelData, Model, or Mesh expected"); #else - return luaL_argerror(L, index, "table or ModelData expected"); + luaL_argerror(L, index, "table or ModelData expected"); #endif + return 0; } diff --git a/src/api/l_filesystem.c b/src/api/l_filesystem.c index ff2cef4c4..387ad7433 100644 --- a/src/api/l_filesystem.c +++ b/src/api/l_filesystem.c @@ -76,8 +76,8 @@ static int luax_loadfile(lua_State* L, const char* path, const char* debug, cons int status = luax_loadbufferx(L, buffer, size, debug, mode); lovrFree(buffer); switch (status) { - case LUA_ERRMEM: return luaL_error(L, "Memory allocation error: %s", lua_tostring(L, -1)); - case LUA_ERRSYNTAX: return luaL_error(L, "Syntax error: %s", lua_tostring(L, -1)); + case LUA_ERRMEM: return luaL_error(L, "Memory allocation error: %s", lua_tostring(L, -1)), 0; + case LUA_ERRSYNTAX: return luaL_error(L, "Syntax error: %s", lua_tostring(L, -1)), 0; default: return 1; } } @@ -219,7 +219,7 @@ static int l_lovrFilesystemGetSize(lua_State* L) { const char* path = luaL_checkstring(L, 1); uint64_t size = lovrFilesystemGetSize(path); if (size == ~0ull) { - return luaL_error(L, "File does not exist"); + return luaL_error(L, "File does not exist"), 0; } lua_pushinteger(L, size); return 1; diff --git a/src/api/l_graphics.c b/src/api/l_graphics.c index 42a6bc02e..05ca470d9 100644 --- a/src/api/l_graphics.c +++ b/src/api/l_graphics.c @@ -218,7 +218,8 @@ static uint32_t luax_checkdatatype(lua_State* L, int index) { const char* string = luaL_checklstring(L, index, &length); if (length < 3) { - return luaL_error(L, "invalid DataType '%s'", string), 0; + luaL_error(L, "invalid DataType '%s'", string); + return 0; } // Deprecated: plurals are allowed and ignored @@ -262,7 +263,8 @@ static uint32_t luax_checkdatatype(lua_State* L, int index) { } } - return luaL_error(L, "invalid DataType '%s'", string), 0; + luaL_error(L, "invalid DataType '%s'", string); + return 0; } uint32_t luax_checkcomparemode(lua_State* L, int index) { @@ -854,7 +856,7 @@ static int l_lovrGraphicsNewTexture(lua_State* L) { } break; case LUA_TNIL: break; - default: return luaL_error(L, "Expected Texture usage to be a string, table, or nil"); + default: luaL_error(L, "Expected Texture usage to be a string, table, or nil"); return 0; } lua_pop(L, 1); diff --git a/src/api/l_math.c b/src/api/l_math.c index af45137fa..d04c77c6d 100644 --- a/src/api/l_math.c +++ b/src/api/l_math.c @@ -332,7 +332,8 @@ static int l_lovrLightUserdataOp(lua_State* L) { return 1; } lua_pop(L, 1); - return luaL_error(L, "Unsupported lightuserdata operator %q", lua_tostring(L, lua_upvalueindex(1))); + luaL_error(L, "Unsupported lightuserdata operator %q", lua_tostring(L, lua_upvalueindex(1))); + return 0; } lua_rawgeti(L, LUA_REGISTRYINDEX, metaref[type]); diff --git a/src/api/l_math_randomGenerator.c b/src/api/l_math_randomGenerator.c index 6590f2f70..6853c9eab 100644 --- a/src/api/l_math_randomGenerator.c +++ b/src/api/l_math_randomGenerator.c @@ -53,7 +53,7 @@ static int l_lovrRandomGeneratorSetState(lua_State* L) { RandomGenerator* generator = luax_checktype(L, 1, RandomGenerator); const char* state = luaL_checklstring(L, 2, NULL); if (lovrRandomGeneratorSetState(generator, state)) { - return luaL_error(L, "invalid random state %s", state); + luaL_error(L, "invalid random state %s", state); } return 0; } diff --git a/src/api/l_math_vectors.c b/src/api/l_math_vectors.c index 4e1afaa60..c2d9b80e1 100644 --- a/src/api/l_math_vectors.c +++ b/src/api/l_math_vectors.c @@ -419,7 +419,8 @@ static int l_lovrVec2__newindex(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to assign property %s of vec2 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to assign property %s of vec2 (invalid property)", lua_tostring(L, -1)); + return 0; } static int l_lovrVec2__index(lua_State* L) { @@ -473,7 +474,8 @@ static int l_lovrVec2__index(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to index field %s of vec2 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to index field %s of vec2 (invalid property)", lua_tostring(L, -1)); + return 0; } int l_lovrVec2__metaindex(lua_State* L) { @@ -811,7 +813,8 @@ static int l_lovrVec3__newindex(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to assign property %s of vec3 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to assign property %s of vec3 (invalid property)", lua_tostring(L, -1)); + return 0; } static int l_lovrVec3__index(lua_State* L) { @@ -865,7 +868,8 @@ static int l_lovrVec3__index(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to index field %s of vec3 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to index field %s of vec3 (invalid property)", lua_tostring(L, -1)); + return 0; } int l_lovrVec3__metaindex(lua_State* L) { @@ -1207,7 +1211,8 @@ static int l_lovrVec4__newindex(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to assign property %s of vec4 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to assign property %s of vec4 (invalid property)", lua_tostring(L, -1)); + return 0; } static int l_lovrVec4__index(lua_State* L) { @@ -1261,7 +1266,8 @@ static int l_lovrVec4__index(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to index field %s of vec4 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to index field %s of vec4 (invalid property)", lua_tostring(L, -1)); + return 0; } int l_lovrVec4__metaindex(lua_State* L) { @@ -1522,7 +1528,8 @@ static int l_lovrQuat__newindex(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to assign property %s of quat (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to assign property %s of quat (invalid property)", lua_tostring(L, -1)); + return 0; } static int l_lovrQuat__index(lua_State* L) { @@ -1557,7 +1564,8 @@ static int l_lovrQuat__index(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to index field %s of quat (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to index field %s of quat (invalid property)", lua_tostring(L, -1)); + return 0; } int l_lovrQuat__metaindex(lua_State* L) { @@ -1967,7 +1975,8 @@ static int l_lovrMat4__newindex(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to assign property %s of mat4 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to assign property %s of mat4 (invalid property)", lua_tostring(L, -1)); + return 0; } static int l_lovrMat4__index(lua_State* L) { @@ -1993,7 +2002,8 @@ static int l_lovrMat4__index(lua_State* L) { lua_getglobal(L, "tostring"); lua_pushvalue(L, 2); lua_call(L, 1, 1); - return luaL_error(L, "attempt to index field %s of mat4 (invalid property)", lua_tostring(L, -1)); + luaL_error(L, "attempt to index field %s of mat4 (invalid property)", lua_tostring(L, -1)); + return 0; } int l_lovrMat4__metaindex(lua_State* L) { diff --git a/src/api/l_physics.c b/src/api/l_physics.c index a8d655978..9de894861 100644 --- a/src/api/l_physics.c +++ b/src/api/l_physics.c @@ -101,7 +101,8 @@ static int l_lovrPhysicsNewWorld(lua_State* L) { if (lua_isstring(L, -1)) { info.tags[i] = lua_tostring(L, -1); } else { - return luaL_error(L, "World tags must be a table of strings"); + luaL_error(L, "World tags must be a table of strings"); + return 0; } lua_pop(L, 1); } @@ -137,7 +138,8 @@ static int l_lovrPhysicsNewWorld(lua_State* L) { if (lua_isstring(L, -1)) { info.tags[i] = lua_tostring(L, -1); } else { - return luaL_error(L, "World tags must be a table of strings"); + luaL_error(L, "World tags must be a table of strings"); + return 0; } lua_pop(L, 1); }