From 93b7f05e54293af4919498fceedb236a523336df Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Fri, 26 May 2023 00:00:00 -0500
Subject: [PATCH 2/3] ps: trade previous fix for final solution to -m option

Well as luck would have it I found yet another missing
field (SCHED_CLASS) that's needed by that '-m' option.
And, while it could just be added to the previous test
of thread_flags and TF_U_m, here is a much better fix.

[ The problem lies with the lists_and_needs function ]
[ where a new format list was created and some print ]
[ functions changed to pr_nop which displays a dash! ]

[ So, by calling the finalize_stacks function before ]
[ calling lists_and_needs, the former will see those ]
[ format nodes before any print function is changed. ]

Reference(s):
May, 2023 - missing fields with -m option
commit 35dc38cb7fcfb71b151a020abb16197b88370337

Signed-off-by: Jim Warner <james.warner@comcast.net>
---
 src/ps/display.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/ps/display.c b/src/ps/display.c
index 46ac844f..e1a3b0da 100644
--- a/src/ps/display.c
+++ b/src/ps/display.c
@@ -600,13 +600,6 @@ static void finalize_stacks (void)
   // special items with 'extra' used as former pcpu
   chkREL(extra)
   chkREL(noop)
-  // lastly, any remaining needs ...
-  if (format_flags & FF_Uf)
-    chkREL(PROCESSOR);
-  if (thread_flags & TF_U_m) {
-    chkREL(PRIORITY);
-    chkREL(WCHAN_NAME);
-  }
 
   // now accommodate any results not yet satisfied
   f_node = format_list;
@@ -676,8 +669,8 @@ int main(int argc, char *argv[]){
 
   init_output(); /* must be between parser and output */
 
-  lists_and_needs();
   finalize_stacks();
+  lists_and_needs();
 
   if(forest_type || sort_list) fancy_spew(); /* sort or forest */
   else simple_spew(); /* no sort, no forest */
-- 
2.33.0

