From af61809a18595a342773745dac351d6ae0e302e1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 24 Jan 2012 00:34:51 -0500 Subject: [PATCH 1/5] include error.h for error() and friends Signed-off-by: Mike Frysinger --- include/c.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/c.h b/include/c.h index 2be74950..747e4e38 100644 --- a/include/c.h +++ b/include/c.h @@ -16,6 +16,7 @@ #include #include #include +#include /* * Compiler specific stuff From 13d8cc0681770d8a358115256b4eb8f98b1b12de Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 24 Jan 2012 00:36:15 -0500 Subject: [PATCH 2/5] watch: include sys/wait.h for waitpid Fixes build warning: watch.c:682:3: warning: implicit declaration of function 'waitpid' [-Wimplicit-function-declaration] Signed-off-by: Mike Frysinger --- watch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/watch.c b/watch.c index 4a2646b2..0bb62391 100644 --- a/watch.c +++ b/watch.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include From afaf69889691a4dad5f69628d8827b88059c144b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 24 Jan 2012 00:40:28 -0500 Subject: [PATCH 3/5] use helpers from c.h A few files still use the C library helpers from err.h, so migrate them to the local c.h helpers. Signed-off-by: Mike Frysinger --- include/xalloc.h | 8 ++++---- proc/sig.c | 3 ++- pwdx.c | 2 +- skill.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/xalloc.h b/include/xalloc.h index bd02c750..37bf0efa 100644 --- a/include/xalloc.h +++ b/include/xalloc.h @@ -24,7 +24,7 @@ void *xmalloc(const size_t size) { void *ret = malloc(size); if (!ret && size) - err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); + xerrx(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); return ret; } @@ -33,7 +33,7 @@ void *xrealloc(void *ptr, const size_t size) { void *ret = realloc(ptr, size); if (!ret && size) - err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); + xerrx(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); return ret; } @@ -42,7 +42,7 @@ void *xcalloc(const size_t nelems, const size_t size) { void *ret = calloc(nelems, size); if (!ret && size && nelems) - err(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); + xerrx(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size); return ret; } @@ -53,7 +53,7 @@ static inline char *xstrdup(const char *str) return NULL; ret = strdup(str); if (!ret) - err(XALLOC_EXIT_CODE, "cannot duplicate string"); + xerrx(XALLOC_EXIT_CODE, "cannot duplicate string"); return ret; } diff --git a/proc/sig.c b/proc/sig.c index 1137fefa..b83e6458 100644 --- a/proc/sig.c +++ b/proc/sig.c @@ -13,6 +13,7 @@ #include #include #include "sig.h" +#include "c.h" /* Linux signals: * @@ -221,7 +222,7 @@ char *strtosig(const char *restrict s){ copy = strdup(s); if (!copy) - err(EXIT_FAILURE, "cannot duplicate string"); + xerrx(EXIT_FAILURE, "cannot duplicate string"); for (p = copy; *p != '\0'; p++) *p = toupper(*p); p = copy; diff --git a/pwdx.c b/pwdx.c index b4aa689c..3d8b71f7 100644 --- a/pwdx.c +++ b/pwdx.c @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) char buf[10 + strlen(argv[i]) + 1]; if (check_pid_argument(argv[i])) - errx(EXIT_FAILURE, _("invalid process id: %s"), + xerrx(EXIT_FAILURE, _("invalid process id: %s"), argv[i]); /* * At this point, all arguments are in the form diff --git a/skill.c b/skill.c index de3ccb94..078624dd 100644 --- a/skill.c +++ b/skill.c @@ -131,7 +131,7 @@ static void check_proc(int pid, struct run_time_conf_t *run_time) if (fd == -1) { /* process exited maybe */ if (run_time->warnings) - warn(_("cannot open file %s"), buf); + xwarn(_("cannot open file %s"), buf); return; } fstat(fd, &statbuf); From 2b449855c7332d16024ef11deec81937880545a5 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 24 Jan 2012 00:41:39 -0500 Subject: [PATCH 4/5] proc: pull in ctype.h where needed Fix the build warnings: sig.c:227:5: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration] sig.c:231:3: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration] Signed-off-by: Mike Frysinger --- proc/sig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/proc/sig.c b/proc/sig.c index b83e6458..b427e01e 100644 --- a/proc/sig.c +++ b/proc/sig.c @@ -8,6 +8,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. */ +#include #include #include #include From 9c32fdbec34d1048879a458bcc60ce5173fe5bb6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 24 Jan 2012 00:44:05 -0500 Subject: [PATCH 5/5] ps: include error.h This code currently uses error_at_line() from error.h, so pull it in. Long term, this might get moved to c.h as a local helper on err.h, but I have no idea. Signed-off-by: Mike Frysinger --- ps/global.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ps/global.c b/ps/global.c index 22cf3ef3..5bddb8c8 100644 --- a/ps/global.c +++ b/ps/global.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include