[PATCH v2 2/7] perf kwork: Replace hard-coded initialization of nr_tracepoints with ARRAY_SIZE macro

From: Yang Jihong
Date: Fri Jul 29 2022 - 23:06:36 EST


Use ARRAY_SIZE macro to replace hard-coded initialization of nr_tracepoints
for future changes.

Suggested-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Yang Jihong <yangjihong1@xxxxxxxxxx>
---
tools/perf/builtin-kwork.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c
index ff17711a554a..2143280c2e95 100644
--- a/tools/perf/builtin-kwork.c
+++ b/tools/perf/builtin-kwork.c
@@ -817,7 +817,7 @@ static void irq_work_name(struct kwork_work *work, char *buf, int len)
static struct kwork_class kwork_irq = {
.name = "irq",
.type = KWORK_CLASS_IRQ,
- .nr_tracepoints = 2,
+ .nr_tracepoints = ARRAY_SIZE(irq_tp_handlers),
.tp_handlers = irq_tp_handlers,
.class_init = irq_class_init,
.work_init = irq_work_init,
@@ -938,7 +938,7 @@ static void softirq_work_name(struct kwork_work *work, char *buf, int len)
static struct kwork_class kwork_softirq = {
.name = "softirq",
.type = KWORK_CLASS_SOFTIRQ,
- .nr_tracepoints = 3,
+ .nr_tracepoints = ARRAY_SIZE(softirq_tp_handlers),
.tp_handlers = softirq_tp_handlers,
.class_init = softirq_class_init,
.work_init = softirq_work_init,
@@ -1035,7 +1035,7 @@ static void workqueue_work_name(struct kwork_work *work, char *buf, int len)
static struct kwork_class kwork_workqueue = {
.name = "workqueue",
.type = KWORK_CLASS_WORKQUEUE,
- .nr_tracepoints = 3,
+ .nr_tracepoints = ARRAY_SIZE(workqueue_tp_handlers),
.tp_handlers = workqueue_tp_handlers,
.class_init = workqueue_class_init,
.work_init = workqueue_work_init,
--
2.30.GIT