{
"lauxlib.h": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 52,
"message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_tolstring) (lua_State *L, int idx, size_t *len);' - Add size_t parameter to specify array capacity",
"rule_id": "API02-C",
"severity": "High",
"suggestion": "Add a size_t parameter after 'size_t *len' to specify the maximum number of elements in the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 55,
"message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_checklstring) (lua_State *L, int arg,' - Add size_t parameter to specify array capacity",
"rule_id": "API02-C",
"severity": "High",
"suggestion": "Add a size_t parameter after 'size_t *l' to specify the maximum number of elements in the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 57,
"message": "Function has pointer parameter without size argument: 'LUALIB_API const char *(luaL_optlstring) (lua_State *L, int arg,' - Add size_t parameter to specify array capacity",
"rule_id": "API02-C",
"severity": "High",
"suggestion": "Add a size_t parameter after 'size_t *l' to specify the maximum number of elements in the array"
},
{
"column": 54,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 58,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 60,
"message": "Incompatible declarations of function 'lua_Number': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 63,
"message": "Incompatible declarations of function 'lua_Integer': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 66,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 67,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 68,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 70,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 71,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 75,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 76,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 76,
"message": "Variadic function declaration should use proper header",
"rule_id": "EXP37-C",
"severity": "Medium",
"suggestion": "Include proper header instead of declaring variadic function"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 78,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 54,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 79,
"message": "Array declaration 'lst[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 82,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 84,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 47,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 84,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 92,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 93,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 95,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 100,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 61,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 100,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 47,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 101,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 65,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 101,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 102,
"message": "Incompatible declarations of function 'int': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 110,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 115,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 119,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 122,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 132,
"message": "Function-like macro 'luaL_newlibtable' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 132,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 132,
"message": "Macro evaluates parameter 'l' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 135,
"message": "Macro 'luaL_newlib' reverses parameter order, creating inconsistent interface",
"rule_id": "API03-C",
"severity": "Medium",
"suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 135,
"message": "Function-like macro 'luaL_newlib' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 135,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 147,
"message": "Function-like macro 'luaL_typename' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 147,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 149,
"message": "Function-like macro 'luaL_dofile' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 149,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 152,
"message": "Function-like macro 'luaL_dostring' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 152,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 157,
"message": "Function-like macro 'luaL_opt' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 157,
"message": "Macro parameter 'f' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'f' in parentheses: (f) instead of f"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 157,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 166,
"message": "Macro parameter 'op' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'op' in parentheses: (op) instead of op"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 201,
"message": "Function-like macro 'luaL_addchar' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 201,
"message": "Macro evaluates parameter 'B' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 209,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 211,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 63,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 211,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 212,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 213,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 214,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 215,
"message": "Incompatible declarations of function 'void': parameter types differ",
"rule_id": "DCL40-C",
"severity": "High",
"suggestion": "Ensure all declarations of the same function have identical signatures"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lauxlib.h",
"line": 258,
"message": "Macro 'luaL_checkint' reverses parameter order, creating inconsistent interface",
"rule_id": "API03-C",
"severity": "Medium",
"suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"
}
],
"lcorolib.c": [
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 25,
"message": "Function returns pointer to local variable 'co' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 18,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 35,
"message": "Implicit boolean test on 'lua_checkstack(co, narg)'. May be unclear what constitutes success or failure.",
"rule_id": "EXP20-C",
"severity": "Medium",
"suggestion": "Use explicit test: lua_checkstack(co, narg) == 0 or lua_checkstack(co, narg) != 0 depending on success convention"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 42,
"message": "Implicit boolean test on 'lua_checkstack(L, nres + 1)'. May be unclear what constitutes success or failure.",
"rule_id": "EXP20-C",
"severity": "Medium",
"suggestion": "Use explicit test: lua_checkstack(L, nres + 1) == 0 or lua_checkstack(L, nres + 1) != 0 depending on success convention"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 76,
"message": "Variable 'r' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const r = ..."
},
{
"column": 26,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 124,
"message": "Array declaration 'statname[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 33,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 128,
"message": "Pointer parameter 'L' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *L'"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 207,
"message": "Array declaration 'co_funcs[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 221,
"message": "Function 'luaopen_coroutine' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lcorolib.c",
"line": 221,
"message": "Function 'luaopen_coroutine' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_coroutine"
}
],
"ldump.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 42,
"message": "Function-like macro 'dumpVector' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 42,
"message": "Macro evaluates parameter 'v' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 44,
"message": "Function-like macro 'dumpLiteral' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 44,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (dumpBlock(D,s,sizeof(s) - sizeof(char)))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 44,
"message": "Macro evaluates parameter 's' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 52,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 40,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 67,
"message": "Division or modulo by 'align' without checking for zero",
"rule_id": "INT33-C",
"severity": "High",
"suggestion": "Check if 'align' is not zero before division"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 69,
"message": "Shared variable 'paddingContent' lacks proper synchronization (not volatile or atomic). This may cause visibility issues across threads.",
"rule_id": "CON03-C",
"severity": "Medium",
"suggestion": "Consider declaring the variable as 'volatile', using atomic types (atomic_int, etc.), or protecting access with mutexes"
},
{
"column": 14,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 73,
"message": "Division or modulo by 'align' without checking for zero",
"rule_id": "INT33-C",
"severity": "High",
"suggestion": "Check if 'align' is not zero before division"
},
{
"column": 32,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 128,
"message": "Variable 'x' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 32,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 128,
"message": "Variable 'l_castS2U' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 6,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 144,
"message": "Direct NULL check for pointer validation. Define and use a dedicated pointer validation function instead of ad-hoc NULL checks. This centralizes validation logic and allows platform-specific enhancements.",
"rule_id": "MEM10-C",
"severity": "Medium",
"suggestion": "Create a validation function like 'int valid(void *ptr)' and use 'if (!valid(ptr))' instead of 'if (ptr == NULL)'"
},
{
"column": 19,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 159,
"message": "Variable 'size' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'size' before use, e.g., at its declaration"
},
{
"column": 16,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 173,
"message": "sizeof applied to pointer/array parameter 'f' which has decayed to a pointer",
"rule_id": "ARR01-C",
"severity": "High",
"suggestion": "Do not use 'sizeof(f->code[0])'. Array/pointer parameters decay to pointers. Pass the array size as a separate parameter instead."
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 207,
"message": "Function 'dumpProtos' participates in indirect recursion: dumpProtos -> dumpFunction -> dumpProtos",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 254,
"message": "Function 'dumpFunction' participates in indirect recursion: dumpFunction -> dumpProtos -> dumpFunction",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 269,
"message": "Function-like macro 'dumpNumInfo' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 269,
"message": "Macro parameter 'tvar' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'tvar' in parentheses: (tvar) instead of tvar"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 269,
"message": "Macro parameter 'value' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'value' in parentheses: (value) instead of value"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 269,
"message": "Multistatement macro 'dumpNumInfo' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 269,
"message": "Macro evaluates parameter 'D' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 288,
"message": "Function 'luaU_dump' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 288,
"message": "Function 'luaU_dump' does not validate pointer parameter 'f' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"
},
{
"column": 65,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 288,
"message": "Pointer parameter 'data' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *data'"
},
{
"column": 9,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 291,
"message": "Memory allocated with 'luaH_new' for variable 'D.h' is not freed",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Add 'free(D.h)' before the variable goes out of scope"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/ldump.c",
"line": 305,
"message": "Memory leak: 'D.h' allocated with 'luaH_new' is not freed before return",
"rule_id": "MEM31-C",
"severity": "High",
"suggestion": "Free 'D.h' before this return statement"
}
],
"lfunc.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 27,
"message": "Function 'luaF_newCclosure' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 29,
"message": "Variable 'c' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const c = ..."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 31,
"message": "Function returns pointer to local variable 'c' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 35,
"message": "Function 'luaF_newLclosure' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 35,
"message": "Function 'luaF_newLclosure' does not validate integer parameter 'nupvals' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'nupvals' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 37,
"message": "Variable 'c' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const c = ..."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 41,
"message": "Function returns pointer to local variable 'c' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 48,
"message": "Function 'luaF_initupvals' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 48,
"message": "Function 'luaF_initupvals' does not validate pointer parameter 'cl' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'cl' at the start of the function, e.g., 'if (!cl) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 74,
"message": "Local variable 'uv' assigned through pointer parameter - address will be invalid when function returns",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Copy data instead of assigning pointer, or use static/allocated storage"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 79,
"message": "Function returns pointer to local variable 'uv' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 9,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 88,
"message": "Pointer-to-pointer assignment may allow const circumvention: **pp = &L->openupval: '**pp = &L->openupval'",
"rule_id": "EXP40-C",
"severity": "Low",
"suggestion": "Either remove const qualifier if the object should be modifiable, or use explicit casts to show intentional const removal"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 91,
"message": "Variable(s) 'p' modified and accessed without sequence point",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification into a separate statement"
},
{
"column": 39,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 91,
"message": "Variable 'p' may be used uninitialized (not assigned on all paths)",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'p' before use, e.g., at its declaration"
},
{
"column": 7,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 94,
"message": "Function returns pointer to local variable 'p' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 11,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 95,
"message": "Potential null pointer dereference in member access of variable 'p'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'p' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 107,
"message": "Function 'callclosemethod' participates in indirect recursion: callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth -> callclosemethod",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 127,
"message": "Function 'checkclosemth' participates in indirect recursion: checkclosemth -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaF_newtbcupval -> checkclosemth",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 145,
"message": "Function 'prepcallclosemth' participates in indirect recursion: prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close -> prepcallclosemth",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 172,
"message": "Function 'luaF_newtbcupval' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 172,
"message": "Function 'luaF_newtbcupval' participates in indirect recursion: luaF_newtbcupval -> checkclosemth -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaV_execute -> luaF_newtbcupval",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 186,
"message": "Function 'luaF_unlinkupval' does not validate pointer parameter 'uv' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'uv' at the start of the function, e.g., 'if (!uv) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 197,
"message": "Function 'luaF_closeupval' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 199,
"message": "Variable(s) 'uv' modified and accessed without sequence point",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification into a separate statement"
},
{
"column": 49,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 199,
"message": "Variable 'uv' may be used uninitialized (not assigned on all paths)",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'uv' before use, e.g., at its declaration"
},
{
"column": 21,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 200,
"message": "Potential null pointer dereference in member access of variable 'uv'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 'uv' is not NULL before member access"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 230,
"message": "Function 'luaF_close' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 230,
"message": "Function 'luaF_close' participates in indirect recursion: luaF_close -> prepcallclosemth -> callclosemethod -> luaD_call -> ccall -> luaD_precall -> precallC -> luaD_poscall -> moveresults -> luaF_close",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 243,
"message": "Function 'luaF_newproto' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 266,
"message": "Function returns pointer to local variable 'f' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 270,
"message": "Function 'luaF_protosize' does not validate pointer parameter 'p' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'p' at the start of the function, e.g., 'if (!p) { return error_code; }'"
},
{
"column": 30,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 270,
"message": "Pointer parameter 'p' is not modified and should be declared const",
"rule_id": "DCL13-C",
"severity": "Low",
"suggestion": "Declare parameter as 'const <type> *p'"
},
{
"column": 15,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 271,
"message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)\n + cast_uint(p->sizelocvars) * sizeof(LocVar)\n + cast_uint(p->sizeupvalues) * sizeof(Upvaldesc)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 15,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 271,
"message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)\n + cast_uint(p->sizelocvars) * sizeof(LocVar)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 15,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 271,
"message": "Scaled integer arithmetic with pointer: 'cast(lu_mem, sizeof(Proto))\n + cast_uint(p->sizep) * sizeof(Proto*)\n + cast_uint(p->sizek) * sizeof(TValue)'. This results in double scaling",
"rule_id": "ARR39-C",
"severity": "High",
"suggestion": "Remove sizeof() or use unscaled integer arithmetic"
},
{
"column": 15,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 271,
"message": "Variable 'p' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 285,
"message": "Function 'luaF_freeproto' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 285,
"message": "Function 'luaF_freeproto' does not validate pointer parameter 'f' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lfunc.c",
"line": 303,
"message": "Function 'luaF_getlocalname' does not validate pointer parameter 'f' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'f' at the start of the function, e.g., 'if (!f) { return error_code; }'"
}
],
"lgc.h": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 46,
"message": "Function-like macro 'issweepphase' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 46,
"message": "Macro evaluates parameter 'g' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 70,
"message": "Macro 'resetbit' reverses parameter order, creating inconsistent interface",
"rule_id": "API03-C",
"severity": "Medium",
"suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 71,
"message": "Macro 'testbit' reverses parameter order, creating inconsistent interface",
"rule_id": "API03-C",
"severity": "Medium",
"suggestion": "Avoid macros that reorder parameters. Maintain consistent parameter ordering across related functions"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 103,
"message": "Function-like macro 'nw2black' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 103,
"message": "Macro evaluates parameter 'x' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 106,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: (cast_byte((g)->currentwhite & WHITEBITS))"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 121,
"message": "Function-like macro 'setage' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 121,
"message": "Macro evaluates parameter 'o' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 204,
"message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 204,
"message": "Macro 'setgcparam' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion",
"rule_id": "PRE05-C",
"severity": "Low",
"suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 205,
"message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 205,
"message": "Macro 'applygcparam' uses token concatenation operator (##) which prevents parameter expansion - consider using two-level macro indirection for proper expansion",
"rule_id": "PRE05-C",
"severity": "Low",
"suggestion": "Use two-level indirection: define a wrapper macro that calls another macro with ##, allowing parameters to expand first"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 229,
"message": "Function-like macro 'condchangemem' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 229,
"message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 229,
"message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 229,
"message": "Multistatement macro 'condchangemem' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 229,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Function-like macro 'luaC_condGC' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Macro parameter 'pre' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'pre' in parentheses: (pre) instead of pre"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Macro parameter 'pos' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'pos' in parentheses: (pos) instead of pos"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: ({ if (G(L)->GCdebt <= 0) { pre; luaC_step(L); pos;}; \\\n\t condchangemem(L,pre,pos,0); })"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Multistatement macro 'luaC_condGC' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 233,
"message": "Macro evaluates parameter 'L' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 241,
"message": "Function-like macro 'luaC_objbarrier' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 241,
"message": "Macro evaluates parameter 'p' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 245,
"message": "Function-like macro 'luaC_barrier' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 245,
"message": "Macro evaluates parameter 'v' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 248,
"message": "Function-like macro 'luaC_objbarrierback' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 248,
"message": "Macro evaluates parameter 'p' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 251,
"message": "Function-like macro 'luaC_barrierback' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lgc.h",
"line": 251,
"message": "Macro evaluates parameter 'v' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
}
],
"lmem.c": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 47,
"message": "Function-like macro 'callfrealloc' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 47,
"message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 47,
"message": "Macro evaluates parameter 'g' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 58,
"message": "Function-like macro 'cantryagain' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 58,
"message": "Macro parameter 'g' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'g' in parentheses: (g) instead of g"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 58,
"message": "Macro evaluates parameter 'g' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 46,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 69,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 97,
"message": "Function 'luaM_growaux_' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 97,
"message": "Function 'luaM_growaux_' does not validate pointer parameter 'block' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'block' at the start of the function, e.g., 'if (!block) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 97,
"message": "Function 'luaM_growaux_' does not validate pointer parameter 'psize' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'psize' at the start of the function, e.g., 'if (!psize) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 97,
"message": "Function 'luaM_growaux_' does not validate integer parameter 'nelems' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'nelems' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 97,
"message": "Function 'luaM_growaux_' does not validate integer parameter 'size_elems' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'size_elems' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 118,
"message": "Function returns pointer to local variable 'newblock' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 128,
"message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 128,
"message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'block' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'block' at the start of the function, e.g., 'if (!block) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 128,
"message": "Function 'luaM_shrinkvector_' does not validate pointer parameter 'size' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'size' at the start of the function, e.g., 'if (!size) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 128,
"message": "Function 'luaM_shrinkvector_' does not validate integer parameter 'size_elem' for overflow before arithmetic operations",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add overflow validation for 'size_elem' before arithmetic, e.g., check against INT_MAX/INT_MIN or use __builtin_*_overflow()"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 136,
"message": "Function returns pointer to local variable 'newblock' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 142,
"message": "Function 'luaM_toobig' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 142,
"message": "Function 'luaM_toobig' participates in indirect recursion: luaM_toobig -> luaG_runerror -> luaG_errormsg -> luaD_callnoyield -> ccall -> luaD_precall -> tryfuncTM -> luaG_callerror -> typeerror -> luaT_objtypename -> luaS_new -> luaS_newlstr -> luaM_toobig",
"rule_id": "MSC04-C",
"severity": "Medium",
"suggestion": "Refactor to eliminate the recursion cycle"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 142,
"message": "Non-void function has no return statement. Control reaching the end of a non-void function without returning a value is undefined behavior.",
"rule_id": "MSC37-C",
"severity": "Medium",
"suggestion": "Add a return statement on all execution paths of this function"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 150,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 151,
"message": "Variable 'g' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const g = ..."
},
{
"column": 43,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 162,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 164,
"message": "Variable 'g' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const g = ..."
},
{
"column": 41,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 176,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 178,
"message": "Variable 'g' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const g = ..."
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 188,
"message": "Function returns pointer to local variable 'newblock' with automatic storage duration",
"rule_id": "DCL30-C",
"severity": "High",
"suggestion": "Use static storage, allocated memory, or pass output buffer as parameter"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 192,
"message": "Function 'luaM_saferealloc_' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 45,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 192,
"message": "Pointer parameter should use conformant array syntax",
"rule_id": "API05-C",
"severity": "High",
"suggestion": "Use conformant array parameter syntax (e.g., 'char p[n]') with the size parameter declared before the array"
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 196,
"message": "Use-after-free: passing freed pointer 'L' to function",
"rule_id": "MEM30-C",
"severity": "Critical",
"suggestion": "Do not pass freed memory to functions."
},
{
"column": 5,
"file": "/home/brandon/toolchain/lua/lmem.c",
"line": 205,
"message": "Variable 'g' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const g = ..."
}
],
"lparser.h": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.h",
"line": 74,
"message": "Function-like macro 'vkisvar' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.h",
"line": 74,
"message": "Macro evaluates parameter 'k' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.h",
"line": 75,
"message": "Function-like macro 'vkisindexed' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lparser.h",
"line": 75,
"message": "Macro evaluates parameter 'k' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
}
],
"ltable.h": [
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 13,
"message": "Macro parameter 'i' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'i' in parentheses: (i) instead of i"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 41,
"message": "Function-like macro 'allocsizenode' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 41,
"message": "Macro evaluates parameter 't' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Function-like macro 'luaH_fastgeti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: ({ Table *h = t; lua_Unsigned u = l_castS2U(k) - 1u; \\\n if ((u < h->asize)) { \\\n tag = *getArrTag(h, u); \\\n if (!tagisempty(tag)) { farr2val(h, u, tag, res); }} \\\n else { tag = luaH_getint(h, (k), res); }})"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Multistatement macro 'luaH_fastgeti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 49,
"message": "Macro evaluates parameter 'k' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Function-like macro 'luaH_fastseti' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Macro parameter 't' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 't' in parentheses: (t) instead of t"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Macro parameter 'hres' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'hres' in parentheses: (hres) instead of hres"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Macro replacement list should be parenthesized to prevent operator precedence issues.",
"rule_id": "PRE02-C",
"severity": "Medium",
"suggestion": "Wrap the entire replacement list in parentheses: ({ Table *h = t; lua_Unsigned u = l_castS2U(k) - 1u; \\\n if ((u < h->asize)) { \\\n lu_byte *tag = getArrTag(h, u); \\\n if (checknoTM(h->metatable, TM_NEWINDEX) || !tagisempty(*tag)) \\\n { fval2arr(h, u, tag, val); hres = HOK; } \\\n else hres = ~cast_int(u); } \\\n else { hres = luaH_psetint(h, k, val); }})"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Multistatement macro 'luaH_fastseti' is not wrapped in a do-while loop. This can cause issues when used in if statements without braces",
"rule_id": "PRE10-C",
"severity": "Medium",
"suggestion": "Wrap the macro body in: do { /* statements */ } while (0)"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 57,
"message": "Macro evaluates parameter 'k' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 130,
"message": "Function-like macro 'arr2obj' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 130,
"message": "Macro evaluates parameter 'h' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 133,
"message": "Function-like macro 'obj2arr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 133,
"message": "Macro evaluates parameter 'h' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 142,
"message": "Function-like macro 'farr2val' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 142,
"message": "Macro evaluates parameter 'res' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 145,
"message": "Function-like macro 'fval2arr' evaluates parameter(s) multiple times; prefer inline or static functions for type safety",
"rule_id": "PRE00-C",
"severity": "Low",
"suggestion": null
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 145,
"message": "Macro parameter 'tag' is not parenthesized in replacement text. This can cause operator precedence issues.",
"rule_id": "PRE01-C",
"severity": "Medium",
"suggestion": "Wrap parameter 'tag' in parentheses: (tag) instead of tag"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/ltable.h",
"line": 145,
"message": "Macro evaluates parameter 'val' multiple times; use inline function instead",
"rule_id": "PRE12-C",
"severity": "Medium",
"suggestion": "Replace macro with inline function to avoid multiple evaluation"
}
],
"lutf8lib.c": [
{
"column": 25,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 53,
"message": "Array declaration 'limits[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 55,
"message": "Variable 'c' is initialized but never modified, consider const-qualifying it",
"rule_id": "DCL00-C",
"severity": "Medium",
"suggestion": "Add 'const' qualifier: const c = ..."
},
{
"column": 13,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 70,
"message": "Variable 'count' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 37,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 70,
"message": "Bitwise operator '<<' used on signed operand 'count' of type 'int'. Use unsigned types for bitwise operations",
"rule_id": "INT13-C",
"severity": "Medium",
"suggestion": "Change 'count' to an unsigned type (e.g., 'unsigned int' instead of 'int')"
},
{
"column": 10,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 81,
"message": "Pointer arithmetic 's + 1' goes 1 elements past the end of array 's[0]'. This exceeds array bounds.",
"rule_id": "ARR00-C",
"severity": "Medium",
"suggestion": "Ensure pointer arithmetic stays within array bounds (0 to 0)"
},
{
"column": 59,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 94,
"message": "Variable 'len' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'len' before use, e.g., at its declaration"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 97,
"message": "Variable(s) 'posi' modified and accessed in unsequenced function arguments",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification from the function call"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 97,
"message": "Variable(s) 'posi' modified and accessed without sequence point",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification into a separate statement"
},
{
"column": 59,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 123,
"message": "Variable 'len' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'len' before use, e.g., at its declaration"
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 142,
"message": "Variable 'code' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'code' before use, e.g., at its declaration"
},
{
"column": 47,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 185,
"message": "Variable 'len' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'len' before use, e.g., at its declaration"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 187,
"message": "Variable(s) 'posi' modified and accessed in unsequenced function arguments",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification from the function call"
},
{
"column": 20,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 187,
"message": "Variable(s) 'posi' modified and accessed without sequence point",
"rule_id": "EXP30-C",
"severity": "High",
"suggestion": "Separate the modification into a separate statement"
},
{
"column": 32,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 191,
"message": "Variable 'posi' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 32,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 191,
"message": "Variable 's' used with both bitwise and arithmetic operations (reduces code readability)",
"rule_id": "INT14-C",
"severity": "Medium",
"suggestion": "Use separate variables for bitwise and arithmetic operations, or refactor to use only arithmetic operators"
},
{
"column": 8,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 219,
"message": "Potential null pointer dereference in array access of variable 's'",
"rule_id": "EXP34-C",
"severity": "High",
"suggestion": "Check if 's' is not NULL before array access"
},
{
"column": 8,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 219,
"message": "Plain 'char' variable 's' used in bit operation (signedness issues)",
"rule_id": "STR00-C",
"severity": "Medium",
"suggestion": "Declare 's' as 'unsigned char' for bit operations"
},
{
"column": 11,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 235,
"message": "Variable 'len' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'len' before use, e.g., at its declaration"
},
{
"column": 34,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 246,
"message": "Variable 'code' is used uninitialized",
"rule_id": "EXP33-C",
"severity": "High",
"suggestion": "Initialize 'code' before use, e.g., at its declaration"
},
{
"column": 23,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 276,
"message": "Array declaration 'funcs[]' has implicit bounds; specify explicit size",
"rule_id": "ARR02-C",
"severity": "Medium",
"suggestion": "Explicitly specify array bounds even when using an initializer"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 288,
"message": "Function 'luaopen_utf8' does not validate pointer parameter 'L' before use",
"rule_id": "API00-C",
"severity": "Medium",
"suggestion": "Add validation check for 'L' at the start of the function, e.g., 'if (!L) { return error_code; }'"
},
{
"column": 1,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 288,
"message": "Function 'luaopen_utf8' should be declared static if it doesn't need external linkage",
"rule_id": "DCL15-C",
"severity": "Low",
"suggestion": "Add 'static' storage-class specifier: static LUAMOD_API luaopen_utf8"
},
{
"column": 3,
"file": "/home/brandon/toolchain/lua/lutf8lib.c",
"line": 291,
"message": "Passing string literal to function 'lua_setfield' which may modify it",
"rule_id": "STR30-C",
"severity": "High",
"suggestion": "Use a modifiable array instead of a string literal"
}
]
}