Stephen Lau wrote: > 2) We throw a "Header guard does not match filename" on a header guard > that looks like: __FOO_H__ (for foo.h) or other things that don't > strictly match _FOO_H_ > Is this the best error message? Intuitively, I would think it should be > "Invalid or missing header guard" myself - but this is the same > behaviour as the gate's hdrchk.pl, so I'm curious what other people think.
I think the two messages are used differently. "Invalid or missing header guard" is already used earlier in the code to indicate that the "#ident" line marking the start of the guard wasn't found where it was expected. "Header guard does not match filename" is used to indicate that the constant value found in the header does not match what was expected based on hdrchk's application of cstyle rules. Incidentally, I wonder if it is possible to tighten up hdrchk's logic here. For example, according to the cstyle rules, <zone.h> should use a guard of "_ZONE_H", while <sys/zone.h> should use a guard of "_SYS_ZONE_H". hdrchk looks only at the basename of the header file, and has a ".*" in the regex to cover any "SYS_", "NET_", etc. in the actual guard. So if there are two headers that share the same basename, it can't strictly enforce the rules. --Nathan