HomeFreeBSD

ps(1): Consider references to keywords as immutable

Description

ps(1): Consider references to keywords as immutable

Building on the previous commit that moved the 'width' field from VAR
(structure representing the meaning of a keyword) to VARENT (structure
representing an actual column in a display), it is now possible to
declare the field 'var' of VARENT as a constant reference.

At this point, it could be possible to constify the var[] array
containing all the recognized keywords. However, we do not do it as
a subsequent commit will change the way alias keywords are resolved,
causing their fields to be modified to reflect the final values to use
after alias resolution.

In parsefmt(), forget about allocating a new VAR for the selected
keyword to be pointed by the corresponding column (VARENT), and instead
just keep a pointer to that structure in var[].

MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49611

(cherry picked from commit 1dbb1cca9b8b7874f22c06f5340686361c76da47)

Details

Provenance
olceAuthored on Feb 28 2025, 9:07 PM
Differential Revision
D49611: ps(1): Constify the array of valid keywords
Parents
rGb1722013af95: ps(1): Move 'width' field from VAR to VARENT; Remove sizevars()
Branches
Unknown
Tags
Unknown