From 5e46a145bafe457abfa8b4f261d6c9a8c41a3c14 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 6 Sep 2015 00:00:00 -0500 Subject: [PATCH] library: ensure any 'flags' is consistently 'unsigned' This commit is an outgrowth of the research into a bug that recently surfaced with the 'w' program. And while that program was just a victim several inconsistencies were found in the handling of library flags during the research. This patch just address such irregularities. Reference(s): http://www.freelists.org/post/procps/newlib-at-the-precipice,4 Signed-off-by: Jim Warner --- proc/pids.c | 2 +- proc/readproc.c | 4 ++-- proc/readproc.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proc/pids.c b/proc/pids.c index 37a1e9f0..ff66cede 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -848,7 +848,7 @@ static inline void oldproc_close ( static inline int oldproc_open ( struct procps_pidsinfo *info, - int supp_flgs, + unsigned supp_flgs, ...) { va_list vl; diff --git a/proc/readproc.c b/proc/readproc.c index 7784ad93..9036f11c 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -1319,7 +1319,7 @@ end_procs: ////////////////////////////////////////////////////////////////////////////////// // initiate a process table scan -PROCTAB* openproc(int flags, ...) { +PROCTAB* openproc(unsigned flags, ...) { va_list ap; struct stat sbuf; static int did_stat; @@ -1401,7 +1401,7 @@ HIDDEN_ALIAS(readeither); * Free allocated memory with exit(). Access via tab[N]->member. The pointer * list is NULL terminated. */ -proc_t** readproctab(int flags, ...) { +proc_t** readproctab(unsigned flags, ...) { PROCTAB* PT = NULL; proc_t** tab = NULL; int n = 0; diff --git a/proc/readproc.h b/proc/readproc.h index 8d69a991..80924716 100644 --- a/proc/readproc.h +++ b/proc/readproc.h @@ -210,7 +210,7 @@ typedef struct PROCTAB { } PROCTAB; // Initialize a PROCTAB structure holding needed call-to-call persistent data -extern PROCTAB* openproc(int flags, ... /* pid_t*|uid_t*|dev_t*|char* [, int n] */ ); +extern PROCTAB* openproc(unsigned flags, ... /* pid_t*|uid_t*|dev_t*|char* [, int n] */ ); typedef struct proc_data_t { // valued by: (else zero) proc_t **tab; // readproctab2, readproctab3 @@ -228,7 +228,7 @@ extern proc_data_t *readproctab3(int(*want_task)(proc_t *buf), PROCTAB *__restri // table subset satisfying the constraints of flags and the optional PID list. // Free allocated memory with exit(). Access via tab[N]->member. The pointer // list is NULL terminated. -extern proc_t** readproctab(int flags, ... /* same as openproc */ ); +extern proc_t** readproctab(unsigned flags, ... /* same as openproc */ ); // Clean-up open files, etc from the openproc() extern void closeproc(PROCTAB* PT);