Skip to content

introduce ares_bool_t datatype - #570

Merged
bradh352 merged 3 commits into
c-ares:mainfrom
bradh352:bool
Oct 13, 2023
Merged

bradh352 merged 3 commits into
c-ares:mainfrom
bradh352:bool

Conversation

@bradh352

@bradh352 bradh352 commented Oct 11, 2023 •

Copy link
Copy Markdown
Member

c-ares currently uses int for boolean, which can be confusing as there are some functions which return int but use '0' as the success condition. Some internal variable usage is similar. Lets try to identify the boolean use cases and split them out into their own data type of ares_bool_t. Since we're trying to keep C89 compatibility, we can't rely on stdbool.h or the _Bool C99 data type, so we'll define our own.

Also, chose using an enum rather than say unsigned char or int because of the type safety benefits it provides. Compilers should warn if you try to pass, ARES_TRUE on to a ares_status_t enum (or similar) since they are different enums.

Fix By: Brad House (@bradh352)

@bradh352
bradh352 requested a review from bagder October 11, 2023 01:56
@bradh352
bradh352 merged commit 75a873c into c-ares:main Oct 13, 2023
@bradh352
bradh352 deleted the bool branch October 13, 2023 10:47
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.

2 participants