diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2014-06-07 07:56:18 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-06-07 07:57:10 -0400 |
commit | 962b3194f525bbb2152d90168b8cd5d5a95a4276 (patch) | |
tree | 2cd97f850f85751bf697236e971e03ea8e326e3a | |
parent | misc/ldd: add caching to speed up recursion (diff) | |
download | elfix-962b3194f525bbb2152d90168b8cd5d5a95a4276.tar.gz elfix-962b3194f525bbb2152d90168b8cd5d5a95a4276.tar.bz2 elfix-962b3194f525bbb2152d90168b8cd5d5a95a4276.zip |
src{fix-gnustack.c,paxctl-ng.c}: portable error reporting
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/fix-gnustack.c | 22 | ||||
-rw-r--r-- | src/paxctl-ng.c | 4 |
3 files changed, 14 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 58a6c16..865cbaf 100644 --- a/configure.ac +++ b/configure.ac @@ -44,7 +44,7 @@ AC_PROG_SED # Checks for header files. AC_CHECK_HEADERS( - [errno.h error.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \ + [errno.h err.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \ sys/mman.h sys/stat.h sys/types.h unistd.h], [], [AC_MSG_ERROR(["Missing necessary header"])] diff --git a/src/fix-gnustack.c b/src/fix-gnustack.c index 0d6ecc1..59e10be 100644 --- a/src/fix-gnustack.c +++ b/src/fix-gnustack.c @@ -19,7 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <error.h> +#include <err.h> #include <libgen.h> #include <gelf.h> @@ -58,7 +58,7 @@ parse_cmd_args( int c, char *v[], int *flagv ) int i, oc; if((c != 2)&&(c != 3)) - error(EXIT_FAILURE, 0, "Usage: %s -f ELF | -h", v[0]); + errx(EXIT_FAILURE, "Usage: %s -f ELF | -h", v[0]); *flagv = 0 ; while((oc = getopt(c, v,":fh")) != -1) @@ -72,7 +72,7 @@ parse_cmd_args( int c, char *v[], int *flagv ) break; case '?': default: - error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; + errx(EXIT_FAILURE, "option -%c is invalid: ignored.", optopt ) ; } return v[optind] ; @@ -93,31 +93,31 @@ main( int argc, char *argv[]) f_name = parse_cmd_args(argc, argv, &flagv); if(elf_version(EV_CURRENT) == EV_NONE) - error(EXIT_FAILURE, 0, "Library out of date."); + errx(EXIT_FAILURE, "Library out of date."); if(flagv) { if((fd = open(f_name, O_RDWR)) < 0) - error(EXIT_FAILURE, 0, "open() fail."); + errx(EXIT_FAILURE, "open() fail."); if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL) - error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno())); + errx(EXIT_FAILURE, "elf_begin() fail: %s", elf_errmsg(elf_errno())); } else { if((fd = open(f_name, O_RDONLY)) < 0) - error(EXIT_FAILURE, 0, "open() fail."); + errx(EXIT_FAILURE, "open() fail."); if((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) - error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno())); + errx(EXIT_FAILURE, "elf_begin() fail: %s", elf_errmsg(elf_errno())); } if(elf_kind(elf) != ELF_K_ELF) - error(EXIT_FAILURE, 0, "elf_kind() fail: this is not an elf file."); + errx(EXIT_FAILURE, "elf_kind() fail: this is not an elf file."); elf_getphdrnum(elf, &phnum); for(i=0; i<phnum; ++i) { if(gelf_getphdr(elf, i, &phdr) != &phdr) - error(EXIT_FAILURE, 0, "gelf_getphdr(): %s", elf_errmsg(elf_errno())); + errx(EXIT_FAILURE, "gelf_getphdr(): %s", elf_errmsg(elf_errno())); if(phdr.p_type == PT_GNU_STACK) { @@ -132,7 +132,7 @@ main( int argc, char *argv[]) printf("W&X FOUND: X flag removed\n"); phdr.p_flags ^= PF_X; if(!gelf_update_phdr(elf, i, &phdr)) - error(EXIT_FAILURE, 0, "gelf_update_phdr(): %s", elf_errmsg(elf_errno())); + errx(EXIT_FAILURE, "gelf_update_phdr(): %s", elf_errmsg(elf_errno())); } } } diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index 8071d50..d340a43 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -20,7 +20,7 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> -#include <error.h> +#include <err.h> #include <libgen.h> #include <sys/types.h> #include <sys/stat.h> @@ -257,7 +257,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c break; case '?': default: - error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; + errx(EXIT_FAILURE, "option -%c is invalid: ignored.", optopt ) ; } } |