# Checks specific to U-Boot
sub u_boot_line {
- my ($realfile, $line, $herecurr) = @_;
+ my ($realfile, $line, $rawline, $herecurr) = @_;
# ask for a test if a new uclass ID is added
if ($realfile =~ /uclass-id.h/ && $line =~ /^\+/) {
ERROR("DEFINE_CONFIG_CMD",
"All commands are managed by Kconfig\n" . $herecurr);
}
+
+ # Don't put common.h and dm.h in header files
+ if ($realfile =~ /\.h$/ && $rawline =~ /^\+#include\s*<(common|dm)\.h>*/) {
+ ERROR("BARRED_INCLUDE_IN_HDR",
+ "Avoid including common.h and dm.h in header files\n" . $herecurr);
+ }
}
sub process {
}
if ($u_boot) {
- u_boot_line($realfile, $line, $herecurr);
+ u_boot_line($realfile, $line, $rawline, $herecurr);
}
# check we are in a valid source file C or perl if not then ignore this hunk
pm.add_line('common/main.c', '#undef CONFIG_CMD_WHICH')
self.checkSingleMessage(pm, 'DEFINE_CONFIG_CMD', 'error')
+ def testBarredIncludeInHdr(self):
+ """Test for using a barred include in a header file"""
+ pm = PatchMaker()
+ #pm.add_line('include/myfile.h', '#include <common.h>')
+ pm.add_line('include/myfile.h', '#include <dm.h>')
+ self.checkSingleMessage(pm, 'BARRED_INCLUDE_IN_HDR', 'error')
+
if __name__ == "__main__":
unittest.main()