From: Craig Small Date: Mon, 2 Mar 2020 11:00:25 +0000 (+1100) Subject: pstree: minor snprintf fix X-Git-Tag: v23.4rc1~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fcc64ab2ca67bc46bdee8d7b50c6c6b9eb09318;p=psmisc pstree: minor snprintf fix The referenced commit used size_t as a return value for snprintf. Coverity found the negative check against size_t but the real problem was using size_t in the first place as an error returned by snprintf would never be detected. References: commit 5e510d1c9ed8cb61f9c504076a7c4828624b8b07 Coverity #288526 --- diff --git a/src/pstree.c b/src/pstree.c index c448539..da02564 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -935,8 +935,7 @@ static char* get_threadname(const pid_t pid, const int tid, const char *comm) FILE *file; char *thread_comm, *endcomm, *threadname; char *path = NULL; - size_t len = 0; - int nbytes; + int len, nbytes; char readbuf[BUFSIZ + 1]; if (! (threadname = malloc(COMM_LEN + 2 + 1))) {