Closed f1f47a23 closed 1 year ago
.... and this is why .... beware of internal variables of the macros
{\ unsigned char buf = (unsigned char)buf_raw;\ buf[0] = (((uint64_t)i) >> 8) & 0xFFUL;\ buf[1] = (((uint64_t)i) >> 0) & 0xFFUL;\ }
Nice find @f1f47a23! Thank you! Would make sense to change var names in macros to something no same person would ever use (?) @RichardAH
Hi. for example
{ unsigned char buf = (unsigned char)bufraw; buf _ [0] = (((uint64t)i) >> 8) & 0xFFUL; buf _ [1] = (((uint64_t)i) >> 0) & 0xFFUL; }
By the way, macros are a bit painful for me. I already asked if there is a way to enable inline functions, to be used in place of macros. I saw that there is also an "always inline" c compiler option.
All macros / compile-time helpers are being moved out of the main repo. Please re-open here if still relevant: https://github.com/XRPLF/hook-macros
Issue Description
while I was studying and modifying the notary.c code, I noticed that variable "buf" had a wrong value. It seems that the problem is related to the "buf" variable name. To get around the problem I had to rename the variable to "buf2"
Steps to Reproduce
Below the changes to notary.c code to reproduce this issue
1) rename all "buf" statements to "buf2"
2) then on line 129 duplicate the buffer
3) finally on line 290 modify as below
Expected Result
trace("buf1",.....) should log: "0002" trace("buf2",.....) logs: "0002"
Actual Result
trace("buf1",.....) logs: "0000" (WRONG!) trace("buf2",.....) logs: "0002"
Environment
online hooks builder https://hooks-builder.xrpl.org
UPDATE
Supporting Files
added fiile "notary-ISSUE-58-Weird-issue(buf-name).zip" including "notary.c.wasm" I did one more test before attaching file
notary-ISSUE-58-Weird-issue(buf-name).zip