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

Fix enif_binary_to_term function declaration mismatch warning #7930

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

mikpe
Copy link
Contributor

@mikpe mikpe commented Dec 2, 2023

Fix function declaration mismatch warning with gcc-13/14:

beam/erl_nif.c:1476:8: warning: conflicting types for 'enif_binary_to_term' due to enum/integer mismatch; have 'size_t(ErlNifEnv *, const unsigned char *, size_t,  ERL_NIF_TERM *, ErlNifBinaryToTerm)' {aka 'long unsigned int(struct enif_environment_t *, const unsigned char *, long unsigned int,  long unsigned int *, ErlNifBinaryToTerm)'} [-Wenum-int-mismatch]
 1476 | size_t enif_binary_to_term(ErlNifEnv *dst_env,
      |        ^~~~~~~~~~~~~~~~~~~
In file included from beam/erl_nif.c:44:
beam/erl_nif_api_funcs.h:174:31: note: previous declaration of 'enif_binary_to_term' with type 'size_t(ErlNifEnv *, const unsigned char *, size_t,  ERL_NIF_TERM *, unsigned int)' {aka 'long unsigned int(struct enif_environment_t *, const unsigned char *, long unsigned int,  long unsigned int *, unsigned int)'}
  174 | ERL_NIF_API_FUNC_DECL(size_t, enif_binary_to_term, (ErlNifEnv *env, const unsigned char* data, size_t sz, ERL_NIF_TERM *term, unsigned int opts));
      |                               ^~~~~~~~~~~~~~~~~~~
beam/erl_nif.h:369:71: note: in definition of macro 'ERL_NIF_API_FUNC_DECL'
  369 | #  define ERL_NIF_API_FUNC_DECL(RET_TYPE, NAME, ARGS) extern RET_TYPE NAME ARGS
      |                                                                       ^~~~

The function definition uses an enum type so I updated the extern declaration to do the same.

Copy link
Contributor

github-actions bot commented Dec 2, 2023

CT Test Results

       3 files     140 suites   47m 39s ⏱️
1 565 tests 1 516 ✔️ 49 💤 0
2 073 runs  2 005 ✔️ 68 💤 0

Results for commit 9bb8038.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Dec 4, 2023
@sverker sverker self-requested a review December 4, 2023 13:13
erts/emulator/beam/erl_nif_api_funcs.h Outdated Show resolved Hide resolved
beam/erl_nif.c:1476:8: warning: conflicting types for 'enif_binary_to_term' due to enum/integer mismatch; have 'size_t(ErlNifEnv *, const unsigned char *, size_t,  ERL_NIF_TERM *, ErlNifBinaryToTerm)' {aka 'long unsigned int(struct enif_environment_t *, const unsigned char *, long unsigned int,  long unsigned int *, ErlNifBinaryToTerm)'} [-Wenum-int-mismatch]
 1476 | size_t enif_binary_to_term(ErlNifEnv *dst_env,
      |        ^~~~~~~~~~~~~~~~~~~
In file included from beam/erl_nif.c:44:
beam/erl_nif_api_funcs.h:174:31: note: previous declaration of 'enif_binary_to_term' with type 'size_t(ErlNifEnv *, const unsigned char *, size_t,  ERL_NIF_TERM *, unsigned int)' {aka 'long unsigned int(struct enif_environment_t *, const unsigned char *, long unsigned int,  long unsigned int *, unsigned int)'}
  174 | ERL_NIF_API_FUNC_DECL(size_t, enif_binary_to_term, (ErlNifEnv *env, const unsigned char* data, size_t sz, ERL_NIF_TERM *term, unsigned int opts));
      |                               ^~~~~~~~~~~~~~~~~~~
beam/erl_nif.h:369:71: note: in definition of macro 'ERL_NIF_API_FUNC_DECL'
  369 | #  define ERL_NIF_API_FUNC_DECL(RET_TYPE, NAME, ARGS) extern RET_TYPE NAME ARGS
      |                                                                       ^~~~

0 is a valid parameter but is not in the enum, so the extern
declaration is the correct one. Changed the function definition,
documentation, and a test case to match.
@mikpe mikpe force-pushed the fix-enif_binary_to_term-type-error branch from c58013a to 9bb8038 Compare December 4, 2023 17:13
@sverker sverker added the bug Issue is reported as a bug label Dec 4, 2023
@mikpe mikpe requested a review from sverker December 9, 2023 13:04
@sverker sverker added the testing currently being tested, tag is used by OTP internal CI label Dec 13, 2023
@sverker
Copy link
Contributor

sverker commented Dec 13, 2023

Due to code freeze this did not make it into 26.2, but is now in the pipe for 26.3.

@sverker sverker added this to the OTP-26.3 milestone Dec 13, 2023
@sverker sverker merged commit 80bf247 into erlang:maint Dec 18, 2023
17 checks passed
@sverker sverker removed the testing currently being tested, tag is used by OTP internal CI label Dec 18, 2023
@mikpe mikpe deleted the fix-enif_binary_to_term-type-error branch December 19, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants