git: 5ad59b91535f - main - intr: merge interrupt table uses of MAXCOMLEN into INTRNAME_LEN
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Aug 2023 22:11:31 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=5ad59b91535f2df176c132be10e344c4a302f619 commit 5ad59b91535f2df176c132be10e344c4a302f619 Author: Elliott Mitchell <ehem+freebsd@m5p.com> AuthorDate: 2023-01-20 02:24:32 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-08-17 22:10:02 +0000 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 --- sys/powerpc/powerpc/intr_machdep.c | 9 +++++---- sys/x86/x86/intr_machdep.c | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c index d64d15775ab5..69a6bda1337f 100644 --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -127,6 +127,7 @@ static u_int nirqs = 0; /* Allocated IRQs. */ #endif static u_int stray_count; +#define INTRNAME_LEN (MAXCOMLEN + 1) u_long *intrcnt; char *intrnames; size_t sintrcnt = sizeof(intrcnt); @@ -152,8 +153,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 @@ -177,10 +178,10 @@ intr_init_sources(void *arg __unused) #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; diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c index 4a1bc942234a..b8dbe3611a42 100644 --- a/sys/x86/x86/intr_machdep.c +++ b/sys/x86/x86/intr_machdep.c @@ -93,6 +93,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); @@ -187,10 +188,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; @@ -428,8 +429,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 @@ -442,14 +443,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];