From e3b777534baeb69a1ee88d0b18c76a68eacdb34e Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 14 Sep 2024 16:15:20 +0300 Subject: [PATCH] procstat(1): make rlimit_param[] size assertion automatic Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46619 --- usr.bin/procstat/procstat_rlimit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usr.bin/procstat/procstat_rlimit.c b/usr.bin/procstat/procstat_rlimit.c index 1881f8ddbeb..3900ef7dcc1 100644 --- a/usr.bin/procstat/procstat_rlimit.c +++ b/usr.bin/procstat/procstat_rlimit.c @@ -47,7 +47,7 @@ static struct { const char *name; const char *suffix; -} rlimit_param[15] = { +} rlimit_param[] = { {"cputime", "sec"}, {"filesize", "B "}, {"datasize", "B "}, @@ -65,9 +65,8 @@ static struct { {"umtxp", " "}, }; -#if RLIM_NLIMITS > 15 -#error "Resource limits have grown. Add new entries to rlimit_param[]." -#endif +_Static_assert(nitems(rlimit_param) == RLIM_NLIMITS, + "Resource limits have grown. Add new entries to rlimit_param[]."); static const char * humanize_rlimit(int indx, rlim_t limit)