]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf/arm-cmn: Improve build-time assertion
authorRobin Murphy <robin.murphy@arm.com>
Mon, 2 Sep 2024 17:52:00 +0000 (18:52 +0100)
committerWill Deacon <will@kernel.org>
Wed, 4 Sep 2024 15:04:08 +0000 (16:04 +0100)
These days we can use static_assert() in the logical place rather than
jamming a BUILD_BUG_ON() into the nearest function scope.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/224ee8286f299100f1c768edb254edc898539f50.1725296395.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/arm-cmn.c

index 48863b31ccfb12c400f770758215a85d228306cf..5b0edeb693946bf0b9fcb4e14f6cd25cec431a07 100644 (file)
@@ -581,6 +581,7 @@ struct arm_cmn_hw_event {
        bool wide_sel;
        enum cmn_filter_select filter_sel;
 };
+static_assert(sizeof(struct arm_cmn_hw_event) <= offsetof(struct hw_perf_event, target));
 
 #define for_each_hw_dn(hw, dn, i) \
        for (i = 0, dn = hw->dn; i < hw->num_dns; i++, dn++)
@@ -591,7 +592,6 @@ struct arm_cmn_hw_event {
 
 static struct arm_cmn_hw_event *to_cmn_hw(struct perf_event *event)
 {
-       BUILD_BUG_ON(sizeof(struct arm_cmn_hw_event) > offsetof(struct hw_perf_event, target));
        return (struct arm_cmn_hw_event *)&event->hw;
 }