From c1e5a7fdad631458768fc45a82b4d43bade8d0c8 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Fri, 28 Feb 2025 10:25:31 +0100 Subject: [PATCH] ps(1): find_varentry() to take a name instead of a VAR The only information that find_varentry() needs and uses is a keyword/var name. The rest of the fields in the passed VAR are unused. Changing its signature will ease introducing new calls to find_varentry() in subsequent commits, as there no VAR object will exist to be passed but just a name. Reviewed by: kib MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49609 --- bin/ps/extern.h | 2 +- bin/ps/keyword.c | 2 +- bin/ps/ps.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ps/extern.h b/bin/ps/extern.h index 48c452aeb84..45b5969f391 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -50,7 +50,7 @@ int donlist(void); char *elapsed(KINFO *, VARENT *); char *elapseds(KINFO *, VARENT *); char *emulname(KINFO *, VARENT *); -VARENT *find_varentry(VAR *); +VARENT *find_varentry(const char *); const char *fmt_argv(char **, char *, char *, size_t); double getpcpu(const KINFO *); char *jailname(KINFO *, VARENT *); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 72fe9e183aa..59011c90617 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -287,7 +287,7 @@ parsefmt(const char *p, struct velisthead *const var_list, * get on with our lives if this VAR is already * represented in the list. */ - vent = find_varentry(v); + vent = find_varentry(v->name); if (vent != NULL) continue; } diff --git a/bin/ps/ps.c b/bin/ps/ps.c index a5ae43b7fad..2a94b4c37f3 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1180,12 +1180,12 @@ init_list(struct listinfo *inf, addelem_rtn artn, int elemsize, } VARENT * -find_varentry(VAR *v) +find_varentry(const char *name) { struct varent *vent; STAILQ_FOREACH(vent, &varlist, next_ve) { - if (strcmp(vent->var->name, v->name) == 0) + if (strcmp(vent->var->name, name) == 0) return vent; } return NULL;