]> granicus.if.org Git - procps-ng/commitdiff
use helpers from c.h
authorMike Frysinger <vapier@gentoo.org>
Tue, 24 Jan 2012 05:40:28 +0000 (00:40 -0500)
committerSami Kerola <kerolasa@iki.fi>
Tue, 24 Jan 2012 07:55:05 +0000 (08:55 +0100)
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 <vapier@gentoo.org>
include/xalloc.h
proc/sig.c
pwdx.c
skill.c

index bd02c75076afc88ee849f7e438b962843034d552..37bf0efa6641c3b6f23cf80ed9122407f35dc03c 100644 (file)
@@ -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;
 }
 
index 1137fefa1d8e1405c7322eaa180701784f96f3dc..b83e6458b5b3edca313c7c7a4b6ec91722875712 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #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 b4aa689c635ea2653a17678263f742d7a036cb48..3d8b71f7be233f113e8e446c79f85f719d23ad2a 100644 (file)
--- 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 de3ccb94a5b5d1edb7501d26c2bf70621b70547c..078624dd640cc3d45cdbd7ebe0669cc13e6491bc 100644 (file)
--- 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);