rem: if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, max_rightward+1, "-"); if(wchan_is_number) return snprintf(outbuf, max_rightward+1, "%x", (unsigned)(pp->wchan) & 0xffffffu); return snprintf(outbuf, max_rightward+1, "%s", lookup_wchan(pp->wchan, pp->XXXID));
add: const char *w; size_t len; if(!(pp->wchan & 0xffffff)) return memcpy(outbuf,"-",2),1; if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu); w = lookup_wchan(pp->wchan, pp->XXXID); len = strlen(w); if(len>max_rightward) len=max_rightward; memcpy(outbuf, w, len); outbuf[len] = '\0'; return len;
context: static int pr_wchan(char *restrict const outbuf, const proc_t *restrict const pp){/* * Unix98 says "blank if running" and also "no blanks"! :-( * Unix98 also says to use '-' if something is meaningless. * Digital uses both '*' and '-', with undocumented differences. * (the '*' for -1 (rare) and the '-' for 0) * Sun claims to use a blank AND use '-', in the same man page. * Perhaps "blank" should mean '-'. * * AIX uses '-' for running processes, the location when there is * only one thread waiting in the kernel, and '*' when there is * more than one thread waiting in the kernel. * * The output should be truncated to maximal columns width -- overflow * is not supported for the "wchan". */    if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, max_rightward+1, "-");    if(wchan_is_number) return snprintf(outbuf, max_rightward+1, "%x", (unsigned)(pp->wchan) & 0xffffffu);    return snprintf(outbuf, max_rightward+1, "%s", lookup_wchan(pp->wchan, pp->XXXID));}