git: 8056c9649171 - stable/14 - libprocstat: change psc_type_info array to use designated initializers

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 31 Mar 2025 02:41:52 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8056c964917156e5a824a5fa78826b7746ce7567

commit 8056c964917156e5a824a5fa78826b7746ce7567
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-03-15 00:28:07 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-03-31 02:41:32 +0000

    libprocstat: change psc_type_info array to use designated initializers
    
    (cherry picked from commit ba2fb6b367fd513ea5812a496254d3a05ec380b8)
---
 lib/libprocstat/core.c | 60 ++++++++++++++++++++++++++++++++++++++++----------
 lib/libprocstat/core.h |  2 +-
 2 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/lib/libprocstat/core.c b/lib/libprocstat/core.c
index cf3435a10c79..1f64e728b0af 100644
--- a/lib/libprocstat/core.c
+++ b/lib/libprocstat/core.c
@@ -62,18 +62,54 @@ static struct psc_type_info {
 	unsigned int	n_type;
 	int		structsize;
 } psc_type_info[PSC_TYPE_MAX] = {
-	{ .n_type  = NT_PROCSTAT_PROC, .structsize = sizeof(struct kinfo_proc) },
-	{ .n_type = NT_PROCSTAT_FILES, .structsize = sizeof(struct kinfo_file) },
-	{ .n_type = NT_PROCSTAT_VMMAP, .structsize = sizeof(struct kinfo_vmentry) },
-	{ .n_type = NT_PROCSTAT_GROUPS, .structsize = sizeof(gid_t) },
-	{ .n_type = NT_PROCSTAT_UMASK, .structsize = sizeof(u_short) },
-	{ .n_type = NT_PROCSTAT_RLIMIT, .structsize = sizeof(struct rlimit) * RLIM_NLIMITS },
-	{ .n_type = NT_PROCSTAT_OSREL, .structsize = sizeof(int) },
-	{ .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
-	{ .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
-	{ .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
-	{ .n_type = NT_PROCSTAT_AUXV, .structsize = sizeof(Elf_Auxinfo) },
-	{ .n_type = NT_PTLWPINFO, .structsize = sizeof(struct ptrace_lwpinfo) },
+	[PSC_TYPE_PROC] = {
+		.n_type  = NT_PROCSTAT_PROC,
+		.structsize = sizeof(struct kinfo_proc)
+	},
+	[PSC_TYPE_FILES] = {
+		.n_type = NT_PROCSTAT_FILES,
+		.structsize = sizeof(struct kinfo_file)
+	},
+	[PSC_TYPE_VMMAP] = {
+		.n_type = NT_PROCSTAT_VMMAP,
+		.structsize = sizeof(struct kinfo_vmentry)
+	},
+	[PSC_TYPE_GROUPS] = {
+		.n_type = NT_PROCSTAT_GROUPS,
+		.structsize = sizeof(gid_t)
+	},
+	[PSC_TYPE_UMASK] = {
+		.n_type = NT_PROCSTAT_UMASK,
+		.structsize = sizeof(u_short)
+	},
+	[PSC_TYPE_RLIMIT] = {
+		.n_type = NT_PROCSTAT_RLIMIT,
+		.structsize = sizeof(struct rlimit) * RLIM_NLIMITS
+	},
+	[PSC_TYPE_OSREL] = {
+		.n_type = NT_PROCSTAT_OSREL,
+		.structsize = sizeof(int)
+	},
+	[PSC_TYPE_PSSTRINGS] = {
+		.n_type = NT_PROCSTAT_PSSTRINGS,
+		.structsize = sizeof(vm_offset_t)
+	},
+	[PSC_TYPE_ARGV] = {
+		.n_type = NT_PROCSTAT_PSSTRINGS,
+		.structsize = sizeof(vm_offset_t)
+	},
+	[PSC_TYPE_ENVV] = {
+		.n_type = NT_PROCSTAT_PSSTRINGS,
+		.structsize = sizeof(vm_offset_t)
+	},
+	[PSC_TYPE_AUXV] = {
+		.n_type = NT_PROCSTAT_AUXV,
+		.structsize = sizeof(Elf_Auxinfo)
+	},
+	[PSC_TYPE_PTLWPINFO] = {
+		.n_type = NT_PTLWPINFO,
+		.structsize = sizeof(struct ptrace_lwpinfo)
+	},
 };
 
 static bool	core_offset(struct procstat_core *core, off_t offset);
diff --git a/lib/libprocstat/core.h b/lib/libprocstat/core.h
index d6cb60dc9e25..8f6aa40192da 100644
--- a/lib/libprocstat/core.h
+++ b/lib/libprocstat/core.h
@@ -31,7 +31,7 @@
 #define _CORE_H
 
 enum psc_type {
-	PSC_TYPE_PROC,
+	PSC_TYPE_PROC = 0,
 	PSC_TYPE_FILES,
 	PSC_TYPE_VMMAP,
 	PSC_TYPE_GROUPS,