ps: ensure functions not called prior to setREL macros

Under newlib design, ps must loop though all potential
print functions so as to gather the appropriate enum's
while establishing the 'relative' equivalent. The keys
to the setREL/chkREL macros are a NULL 'outbuf' param.

It's imperative that no other functions be called with
that NULL value. Unfortunately, several instances were
found where this was violated. They are now corrected!

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2018-06-06 00:00:00 -05:00 committed by Craig Small
parent 292a4dd6fa
commit 26ab9ae143

View File

@ -274,8 +274,9 @@ Modifications to the arguments are not shown.
static int pr_args(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
int rightward = max_rightward;
int fh = forest_helper(outbuf);
int fh;
setREL2(CMDLINE,ENVIRON)
fh = forest_helper(outbuf);
endp += fh;
rightward -= fh;
endp += escaped_copy(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE, &rightward);
@ -297,8 +298,9 @@ setREL2(CMDLINE,ENVIRON)
static int pr_comm(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
int rightward = max_rightward;
int fh = forest_helper(outbuf);
int fh;
setREL3(CMD,CMDLINE,ENVIRON)
fh = forest_helper(outbuf);
endp += fh;
rightward -= fh;
if(unix_f_option)
@ -335,8 +337,9 @@ setREL1(CGROUP)
static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf;
int rightward = max_rightward;
int fh = forest_helper(outbuf);
int fh;
setREL1(CMD)
fh = forest_helper(outbuf);
endp += fh;
rightward -= fh;
if (rightward>8) /* 8=default, but forest maybe feeds more */