Skip to content

ares_status_t enum for status codes #567

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 6 commits into from
Oct 10, 2023
Merged

Conversation

bradh352
Copy link
Member

The list of possible error codes in c-ares was a #define list. This not only doesn't provide for any sort of type safety but it also lacks clarification on what a function may return or what it takes, as an int could be an ares status, a boolean, or possibly even a length in the current code.

We are not changing any public APIs as though the C standard states the underlying size and type of an enum is int, there are compiler attributes to override this as well as compiler flags like -fshort-enums. GCC in particular is known to expand an enum's width based on the data values (e.g., it can emit a 64bit integer enum).

All internal usages should be changed by this PR, but of course, there may be some I missed.

Fix By: Brad House (@bradh352)

@bradh352 bradh352 requested a review from bagder October 10, 2023 14:14
bradh352 and others added 3 commits October 10, 2023 12:01
err -> status

Co-authored-by: Daniel Stenberg <daniel@haxx.se>
err -> status

Co-authored-by: Daniel Stenberg <daniel@haxx.se>
@bradh352 bradh352 merged commit 973023b into c-ares:main Oct 10, 2023
@bradh352 bradh352 deleted the ares_status branch October 10, 2023 16:42
@gvanem
Copy link
Contributor

gvanem commented Oct 11, 2023

What about ares_set_sortlist()etc.? Still many hits for int ares_.

@bradh352
Copy link
Member Author

bradh352 commented Oct 11, 2023

What about ares_set_sortlist()etc.? Still many hits for int ares_.

I have intentionally not changed any public API interfaces as it could break ABI compatibility. Compilers aren't guaranteed to internally use int for an enum, especially if someone is compiling their code using GCC and are specifying -fshort-enums.

non-public hits for int ares_* might be addressed by #570 ... as I think I got all of them that don't return weird codes like -1, 0, 1.

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.

3 participants