diff options
author | Elliott Mitchell <ehem+freebsd@m5p.com> | 2023-01-20 02:24:32 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2023-08-31 13:24:05 +0000 |
commit | b5f0f20e9bd1999d9c606f2a20a08a54c7f5ccfe (patch) | |
tree | 1cf7d2efdb59316e5a9f8b60d0daf66819356f52 /sys/x86 | |
parent | e8deaa3c6b8b98f435a07b47aaf3c546e7e876d5 (diff) |
intr: merge interrupt table uses of MAXCOMLEN into INTRNAME_LEN
The repeated uses of `MAXCOMLEN + 1` seem a bit hazardous. If there was
a future need to change the size, the repeats will be troublesome.
Merge everything into `#define INTRNAME_LEN` (matches the name used by
INTRNG).
Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38455
(cherry picked from commit 5ad59b91535f2df176c132be10e344c4a302f619)
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/intr_machdep.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c index b89af6c4c2a1..d7c325c82399 100644 --- a/sys/x86/x86/intr_machdep.c +++ b/sys/x86/x86/intr_machdep.c @@ -95,6 +95,7 @@ u_int num_io_irqs; static int assign_cpu; #endif +#define INTRNAME_LEN (MAXCOMLEN + 1) u_long *intrcnt; char *intrnames; size_t sintrcnt = sizeof(intrcnt); @@ -189,10 +190,10 @@ intr_init_sources(void *arg) #endif intrcnt = mallocarray(nintrcnt, sizeof(u_long), M_INTR, M_WAITOK | M_ZERO); - intrnames = mallocarray(nintrcnt, MAXCOMLEN + 1, M_INTR, M_WAITOK | + intrnames = mallocarray(nintrcnt, INTRNAME_LEN, M_INTR, M_WAITOK | M_ZERO); sintrcnt = nintrcnt * sizeof(u_long); - sintrnames = nintrcnt * (MAXCOMLEN + 1); + sintrnames = nintrcnt * INTRNAME_LEN; intrcnt_setname("???", 0); intrcnt_index = 1; @@ -430,8 +431,8 @@ static void intrcnt_setname(const char *name, int index) { - snprintf(intrnames + (MAXCOMLEN + 1) * index, MAXCOMLEN + 1, "%-*s", - MAXCOMLEN, name); + snprintf(intrnames + INTRNAME_LEN * index, INTRNAME_LEN, "%-*s", + INTRNAME_LEN - 1, name); } static void @@ -444,14 +445,14 @@ intrcnt_updatename(struct intsrc *is) static void intrcnt_register(struct intsrc *is) { - char straystr[MAXCOMLEN + 1]; + char straystr[INTRNAME_LEN]; KASSERT(is->is_event != NULL, ("%s: isrc with no event", __func__)); mtx_lock_spin(&intrcnt_lock); MPASS(intrcnt_index + 2 <= nintrcnt); is->is_index = intrcnt_index; intrcnt_index += 2; - snprintf(straystr, MAXCOMLEN + 1, "stray irq%d", + snprintf(straystr, sizeof(straystr), "stray irq%d", is->is_pic->pic_vector(is)); intrcnt_updatename(is); is->is_count = &intrcnt[is->is_index]; |