Skip to content

use unsigned char* for the fn pointer type #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

jiridanek
Copy link
Contributor

When the type is just char*, I get a lot of -Woverflow warnings from the compiler

main.cpp:22:
cpp-stub/stub.h: In instantiation of ‘void Stub::set(T, S) [with T = int (*)(int); S = int (*)(int)]’:
main.cpp:42:17:   required from here
cpp-stub/stub.h:209:21: error: overflow in conversion from ‘int’ to ‘char’ changes value from ‘187’ to ‘-69’ [-Werror=overflow]
  209 |         *(fn + 1) = 0xbb;\
      |                     ^~~~
cpp-stub/stub.h:327:13: note: in expansion of macro ‘REPLACE_FAR’
  327 |             REPLACE_FAR(this, fn, fn_stub);
      |             ^~~~~~~~~~~

When the type is just `char*`, I get a lot of -Woverflow warnings from the compiler

```
main.cpp:22:
cpp-stub/stub.h: In instantiation of ‘void Stub::set(T, S) [with T = int (*)(int); S = int (*)(int)]’:
main.cpp:42:17:   required from here
cpp-stub/stub.h:209:21: error: overflow in conversion from ‘int’ to ‘char’ changes value from ‘187’ to ‘-69’ [-Werror=overflow]
  209 |         *(fn + 1) = 0xbb;\
      |                     ^~~~
cpp-stub/stub.h:327:13: note: in expansion of macro ‘REPLACE_FAR’
  327 |             REPLACE_FAR(this, fn, fn_stub);
      |             ^~~~~~~~~~~
```
```
In file included from main.cpp:22:
cpp-stub/stub.h:276:28: error: cannot initialize a parameter of type 'char *' with an lvalue of type 'unsigned char *'
  276 |                 CACHEFLUSH(pstub->fn, CODESIZE);
      |                            ^~~~~~~~~
cpp-stub/stub.h:28:56: note: expanded from macro 'CACHEFLUSH'
   28 | #define CACHEFLUSH(addr, size) __builtin___clear_cache(addr, addr + size)
      |                                                        ^~~~
```
@coolxv coolxv merged commit 3fba0ff into coolxv:master Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants