summaryrefslogtreecommitdiffstats
path: root/sys-utils/setarch.c
diff options
context:
space:
mode:
authorFrancesco Cosoleto2011-06-02 21:17:57 +0200
committerKarel Zak2011-06-08 13:09:18 +0200
commitc60103a9f3e06fc1cd11f0a5ed83c0d12a631224 (patch)
tree360e7662ea0461798520ff65842206a3aa722e6d /sys-utils/setarch.c
parenttests: add lscpu dumps from three Dell's & a Xen (diff)
downloadkernel-qcow2-util-linux-c60103a9f3e06fc1cd11f0a5ed83c0d12a631224.tar.gz
kernel-qcow2-util-linux-c60103a9f3e06fc1cd11f0a5ed83c0d12a631224.tar.xz
kernel-qcow2-util-linux-c60103a9f3e06fc1cd11f0a5ed83c0d12a631224.zip
fstrim, setarch: replace error() with err()
This should improve a bit the portability as error() is a GNU extension and util-linux provides fallbacks for err.h functions. Fix compilation with icc, broken due to a reference to `__builtin_va_arg_pack' in error.h using the -gcc default option. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
Diffstat (limited to 'sys-utils/setarch.c')
-rw-r--r--sys-utils/setarch.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index 76f743fe5..5f187a764 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -30,12 +30,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <errno.h>
-#include <error.h>
#include <getopt.h>
#include <limits.h>
#include <sys/utsname.h>
#include "nls.h"
+#include "c.h"
#define set_pers(pers) ((long)syscall(SYS_personality, pers))
@@ -212,7 +211,7 @@ int set_arch(const char *pers, unsigned long options)
break;
if(transitions[i].perval < 0)
- error(EXIT_FAILURE, 0, _("%s: Unrecognized architecture"), pers);
+ errx(EXIT_FAILURE, _("%s: Unrecognized architecture"), pers);
pers_value = transitions[i].perval | options;
res = set_pers(pers_value);
@@ -228,7 +227,7 @@ int set_arch(const char *pers, unsigned long options)
&& strcmp(un.machine, "i586")
&& strcmp(un.machine, "i686")
&& strcmp(un.machine, "athlon")))
- error(EXIT_FAILURE, 0, _("%s: Unrecognized architecture"), pers);
+ errx(EXIT_FAILURE, _("%s: Unrecognized architecture"), pers);
}
return 0;
@@ -262,9 +261,9 @@ int main(int argc, char *argv[])
#if defined(__sparc64__) || defined(__sparc__)
if (!strcmp(p, "sparc32bash")) {
if (set_arch(p, 0L))
- error(EXIT_FAILURE, errno, _("Failed to set personality to %s"), p);
+ err(EXIT_FAILURE, _("Failed to set personality to %s"), p);
execl("/bin/bash", NULL);
- error(EXIT_FAILURE, errno, "/bin/bash");
+ err(EXIT_FAILURE, "/bin/bash");
}
#endif
@@ -315,14 +314,14 @@ int main(int argc, char *argv[])
argv += optind;
if (set_arch(p, options))
- error(EXIT_FAILURE, errno, _("Failed to set personality to %s"), p);
+ err(EXIT_FAILURE, _("Failed to set personality to %s"), p);
if (!argc) {
execl("/bin/sh", "-sh", NULL);
- error(EXIT_FAILURE, errno, "/bin/sh");
+ err(EXIT_FAILURE, "/bin/sh");
}
execvp(argv[0], argv);
- error(EXIT_FAILURE, errno, "%s", argv[0]);
+ err(EXIT_FAILURE, "%s", argv[0]);
return EXIT_FAILURE;
}