git: ba2fb6b367fd - main - libprocstat: change psc_type_info array to use designated initializers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 24 Mar 2025 02:24:54 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ba2fb6b367fd513ea5812a496254d3a05ec380b8 commit ba2fb6b367fd513ea5812a496254d3a05ec380b8 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-03-15 00:28:07 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-03-24 02:24:14 +0000 libprocstat: change psc_type_info array to use designated initializers Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49372 --- 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 c02ab9511af7..83aabc50cc30 100644 --- a/lib/libprocstat/core.c +++ b/lib/libprocstat/core.c @@ -61,18 +61,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,