git: b5f0f20e9bd1 - stable/13 - intr: merge interrupt table uses of MAXCOMLEN into INTRNAME_LEN
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 31 Aug 2023 13:55:36 UTC
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=b5f0f20e9bd1999d9c606f2a20a08a54c7f5ccfe
commit b5f0f20e9bd1999d9c606f2a20a08a54c7f5ccfe
Author: Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2023-01-20 02:24:32 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-08-31 13:24:05 +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
(cherry picked from commit 5ad59b91535f2df176c132be10e344c4a302f619)
---
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 605f436804d4..c314a2c928bc 100644
--- a/sys/powerpc/powerpc/intr_machdep.c
+++ b/sys/powerpc/powerpc/intr_machdep.c
@@ -129,6 +129,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);
@@ -154,8 +155,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
@@ -179,10 +180,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 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];