Skip to content
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

Make the PIC macro confuse the type checker less #225

Open
xchapron-ledger opened this issue Mar 23, 2023 · 1 comment
Open

Make the PIC macro confuse the type checker less #225

xchapron-ledger opened this issue Mar 23, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@xchapron-ledger
Copy link
Contributor

See LedgerHQ/nanox-secure-sdk#13

@xchapron-ledger xchapron-ledger added the enhancement New feature or request label Mar 23, 2023
@xchapron-ledger
Copy link
Contributor Author

@Ericson2314 in LedgerHQ/nanox-secure-sdk#13 your are proposing to change PIC macro to:
#define PIC(x) ((typeof(x)) pic((void *)x))
Sadly this is raising issue on many apps.
For example for app with code like: https://github.com/LedgerHQ/app-boilerplate/blob/c46ba042298e06bb7b168d375398fdb0cca51823/src/handler/get_app_name.c#L28-L34
This lead to build issue:

[CC]   build/nanox/obj/get_app_name.o
src/handler/get_app_name.c:32:42: error: used type 'typeof ("my_app")' (aka 'char [7]') where arithmetic or pointer type is required
    buffer_t rdata = {.ptr = (uint8_t *) PIC(MYAPPNAME), .size = APPNAME_LEN, .offset = 0};
                                         ^~~~~~~~~~~~~~
/home/xchapron/Workspace/LedgerHQ/ledger-secure-sdk/include/os_pic.h:10:17: note: expanded from macro 'PIC'
#define PIC(x) ((typeof(x)) pic((void *)x))
                ^           ~~~~~~~~~~~~~~
1 error generated.

This issue can be fixed by changing on app side:
buffer_t rdata = {.ptr = (uint8_t *) PIC(APPNAME), .size = APPNAME_LEN, .offset = 0};
By:
buffer_t rdata = {.ptr = (uint8_t *) PIC(&APPNAME[0]), .size = APPNAME_LEN, .offset = 0};

But requiring this is not really wanted.

Do you know another way to achieve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant