Skip to content

Commit caec7e1

Browse files
committed
fix(WebServer): use static const instead of #define for function pointer
- Change from `#define ORIG_XXX ((fn_t)addr)` to `static fn_t const ORIG_XXX = (fn_t)addr;` - Avoids js-beautify removing space between macro name and parenthesis - More type-safe and debugger-friendly
1 parent e79d545 commit caec7e1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • Tools/WebServer/static/js/features

Tools/WebServer/static/js/features/patch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,10 @@ ${processedBody}
130130
let origFuncDef = '';
131131
if (hasOrigAddr) {
132132
const argList = paramNames.join(', ');
133-
origFuncDef = `/* Original function pointer - call via ORIG_${funcName.toUpperCase()}() to avoid recursion */
133+
const macroName = `ORIG_${funcName.toUpperCase()}`;
134+
origFuncDef = `/* Original function pointer - call via ${macroName}() to avoid recursion */
134135
typedef ${returnType} (*${funcName}_fn_t)(${params || 'void'});
135-
#define ORIG_${funcName.toUpperCase()} ((${funcName}_fn_t)${origAddr})
136+
static ${funcName}_fn_t const ${macroName} = (${funcName}_fn_t)${origAddr};
136137
137138
`;
138139
if (returnType === 'void') {

0 commit comments

Comments
 (0)