[PATCH 2/2] selftests/powerpc/pmu: fix including of utils.h when event.h is included

Benjamin Gray bgray at linux.ibm.com
Thu Mar 2 09:05:46 AEDT 2023


On Wed, 2023-03-01 at 22:39 +0530, Kajol Jain wrote:
> From: Madhavan Srinivasan <maddy at linux.ibm.com>
> 
> event.h header already includes utlis.h. Avoid including
> the same explicitly in the code when event.h included.
> 
> Signed-off-by: Madhavan Srinivasan <maddy at linux.ibm.com>

As I understand, transitive includes should not be depended upon. If
you use a thing, and the thing is declared in a header, you should
include _that_ header. Anything else is a recipe for weird include
dependencies, ordering of the includes, etc.

These files all use FAIL_IF, etc., which are declared in utils.h. So
utils.h is a legitimate include. The fact that events.h also includes
it (for u64) is a coincidence. If the u64 type def gets moved to, e.g.,
types.h, and utils.h is removed from events.h, suddenly all these files
stop compiling.


More information about the Linuxppc-dev mailing list