ares_channel
-> ares_channel_t *
: don't bury the pointer
#595
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ares_channel
is defined astypedef struct ares_channeldata *ares_channel;
. The problem with this, is it embeds the pointer into the typedef, which means anares_channel
can never be declared asconst
as if you writeconst ares_channel channel
, that expands tostruct ares_channeldata * const ares_channel
and notconst struct ares_channeldata *channel
.We will now typedef
ares_channel_t
astypedef struct ares_channeldata ares_channel_t;
, so if you writeconst ares_channel_t *channel
, it properly expands toconst struct ares_channeldata *channel
.We are maintaining the old typedef for API compatibility with existing integrations, and due to typedef expansion this should not even cause any compiler warnings for existing code. There are no ABI implications with this change. I could be convinced to keep existing public functions as
ares_channel
if a sufficient argument exists, but internally we really need make this change for modern best practices.This change will allow us to internally use
const ares_channel_t *
where appropriate. Whether or not we decide to change any public interfaces to useconst
may require further discussion on if there might be ABI implications (I don't think so, but I'm also not 100% sure what a compiler internally does withconst
when emitting machine code ... I think more likely ABI implications would occur going the opposite direction).FYI, This PR was done via a combination of sed and clang-format, the only manual code change was the addition of the new typedef :)
Fix By: Brad House (@bradh352)