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

AVRO-3960: [C] Fix st ANYARGS warning #2798

Merged
merged 1 commit into from
Mar 25, 2024
Merged

AVRO-3960: [C] Fix st ANYARGS warning #2798

merged 1 commit into from
Mar 25, 2024

Conversation

SahilKang
Copy link
Contributor

@SahilKang SahilKang commented Mar 10, 2024

AVRO-3960

What is the purpose of the change

This removes the following warning:

  avro/lang/c/src/st.c:240:13: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not
        supported in C2x [-Wdeprecated-non-prototype]
          hash_val = do_hash(key, table);

Verifying this change

This change is already covered by existing tests, such as make test

Documentation

No new features are added

@github-actions github-actions bot added the C label Mar 10, 2024
@@ -212,7 +212,7 @@ void st_free_table(st_table *table)
}

#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (void*) (key), (void*) (ptr)->key)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the explicit casts to void* needed here and below for MSVC? Or is there some other reason to have them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the void* casts, we get -Wpointer-integer-compare warnings due to st_data_t being a uintptr_t

the other call-sites throughout /avro/lang/c pass in pointers so the cast is only needed for st.c

@mkmkme
Copy link
Contributor

mkmkme commented Mar 12, 2024

Thanks, it's good to have the deprecation warnings go away.

One thing I would suggest, though, since ANYARGS is being replaced with three different function ptrs, is having those function ptr types as typedef-s and casting the functions in-place explicitly, without the macro.

Does it sound reasonable?

This removes the following warning:

  avro/lang/c/src/st.c:240:13: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not
        supported in C2x [-Wdeprecated-non-prototype]
          hash_val = do_hash(key, table);

Signed-off-by: Sahil Kang <[email protected]>
Signed-off-by: Sahil Kang <[email protected]>
@SahilKang
Copy link
Contributor Author

good idea, I changed the macros to typedefs

@martin-g martin-g merged commit 03ea96b into apache:main Mar 25, 2024
5 checks passed
@martin-g
Copy link
Member

Thank you, @SahilKang !

@SahilKang SahilKang deleted the c-st branch April 20, 2024 05:51
RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
This removes the following warning:

  avro/lang/c/src/st.c:240:13: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not
        supported in C2x [-Wdeprecated-non-prototype]
          hash_val = do_hash(key, table);

Signed-off-by: Sahil Kang <[email protected]>
Signed-off-by: Sahil Kang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants