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

gcc -pedantic cleaning patch (function pointer to/from object pointer casting) #2131

Open
maqifrnswa opened this issue Dec 9, 2024 · 0 comments

Comments

@maqifrnswa
Copy link

maqifrnswa commented Dec 9, 2024

Building with target_compile_options(proj_name PRIVATE -Wpedantic), there are a bunch of extra warnings in the sdk. I fixed the ones I saw for the rp2040 here:
maqifrnswa@7253859

I wanted to check to see if there's an interest in cleaning these up. If so, I can work through the rp2350 as well and prepare a better commit.

Summary:

  1. Most of them are for casting function pointers to/from object pointers (/.pico-sdk/sdk/2.1.0/src/rp2_common/hardware_flash/flash.c:120:65: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]).
    I went through and changed functions that returned function pointers from:
    void *function_name(args); // which is a function that returns a pointer to data
    to
    void (* function_name(args))(void); // a func. that returns a function pointer
    Some functions return a data pointer or a func pointer, so I changed them from:
    void *function_name(args);
    to
    uintptr_t function_name(args); // this allows casting to either a func or data pointer
    To be super-super-super pedantic, things should be specific about whether they are returning a function pointer or data pointer. uintptr_t isn't ideal for function pointers, but I think (IMO) it's fine to use uintptr_t with these architectures since it is often used for cases like this where you have a ROM address that may be a function or data.

  2. a couple stray ; from ISO C does not allow extra ';' outside of a function [-Wpedantic]

  3. converted binary constants to hex binary constants are a C2X feature or GCC extension

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

No branches or pull requests

1 participant