-
Notifications
You must be signed in to change notification settings - Fork 516
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
Maintenance: Polish fqdncache.h #1848
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this cleanup.
@@ -11,19 +11,17 @@ | |||
#ifndef SQUID_SRC_FQDNCACHE_H | |||
#define SQUID_SRC_FQDNCACHE_H | |||
|
|||
#include "ip/Address.h" | |||
#include "dns/forward.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explicitly include ip/forward.h instead of starting to rely on current side effects of dns/forward.h inclusion (to get a forward declaration of Ip::Address).
#include "dns/forward.h" | |
#include "dns/forward.h" | |
#include "ip/forward.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dns/forward.h
includes ip/forward.h
, no need to include it twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dns/forward.h
includesip/forward.h
Yes, my change request is based on this fact.
no need to include it twice.
To get the current code compiled, we do not need to include it explicitly (as already acknowledged in my change request).
To avoid relying on side effects, we do need to include it explicitly (as already stated in my change request). This reason is enough to include ip/forward.h explicitly despite the current code compiling without that explicit inclusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yet in #1848 (comment) you requested we rely on a side-effect of including the namespace Store
forward declarations to also provide a global type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yet in #1848 (comment) you requested we rely on a side-effect of including the
namespace Store
forward declarations
I did not:
- That change request is about using a reliable/direct/intended effect of store/forward.h header -- import of Store forward declarations. A foo/forward.h header exists exactly for that purpose -- it provides Foo forward declarations.
- This change request is about avoiding current side effects of dns/forward.h header. A foo/forward.h header is not meant to be used for Bar forward declarations (and may not provide them or stop providing them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your definition of "side-effects" in this case is wrongly applied. The dns/forward.h
provides the declarations for libdns API. The storage type(s) used for DNS responses (eg. Ip::Address
) are part of that and always will be - the definition(s) will be provided via dns/forward.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
dns/forward.h
provides the declarations for libdns API.
dns/forward.h should provide forward declarations for libdns API. Today, it also provides three function declarations, but that (hopefully temporary) violation is not to be relied on when making design decisions (not to mention relying on side effects of that violation!).
The storage type(s) used for DNS responses (eg. Ip::Address) are part of that and always will be
Ip::Address is not a part of libdns forward declarations today, and even if it becomes a part of them tomorrow, it is not something libdns users should rely on.
The relevant rule of thumb is quite simple: If header B.h uses a name declared in header A.h, then B.h should include either A/forward.h (if sufficient to get B.h compiled) or header A.h itself (otherwise).
Co-authored-by: Alex Rousskov <[email protected]>
@@ -11,19 +11,17 @@ | |||
#ifndef SQUID_SRC_FQDNCACHE_H | |||
#define SQUID_SRC_FQDNCACHE_H | |||
|
|||
#include "ip/Address.h" | |||
#include "dns/forward.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dns/forward.h
includesip/forward.h
Yes, my change request is based on this fact.
no need to include it twice.
To get the current code compiled, we do not need to include it explicitly (as already acknowledged in my change request).
To avoid relying on side effects, we do need to include it explicitly (as already stated in my change request). This reason is enough to include ip/forward.h explicitly despite the current code compiling without that explicit inclusion.
No description provided.