Eric Blake wrote:
On 03/01/2012 09:53 AM, Daniel P. Berrange wrote:
> On Thu, Mar 01, 2012 at 11:43:04AM -0500, Laine Stump wrote:
>> Commit 7c90026 added #include "conf/domain_conf.h" to
>> util/virrandom.c. Fortunately it didn't actually use anything from
>> domain_conf.h, since as far as I'm aware, files in util aren't allowed
>> to reference anything in conf (although the opposite is allowed). So
>> this #include is unnecessary.
>
> That is correct. util/ must be self-contained
Guess what - that sounds like a great syntax rule to write, so we don't
slip up in the future. Give me a few minutes, to see what I can come up
with. Any other directories that should be avoiding particular includes?
I noticed Laine's message, admired his control and wrote this,
came back to reply and found your message.
Laine, you're welcome to merge this into your commit.
diff --git a/cfg.mk b/cfg.mk
index ac6c527..ca6fe65 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -624,6 +624,13 @@ sc_prohibit_gettext_markup:
halt='do not mark these strings for translation' \
$(_sc_search_regexp)
+# One must not include conf/ headers from src/util/.
+sc_prohibit_conf_inclusion_from_util:
+ @in_vc_files='^src/util/' \
+ prohibit='^# *include "conf/' \
+ halt='do not include conf/*.h from src/util/*' \
+ $(_sc_search_regexp)
+
# When converting an enum to a string, make sure that we track any new
# elements added to the enum by using a _LAST marker.
sc_require_enum_last_marker: