commit: 962b3194f525bbb2152d90168b8cd5d5a95a4276
Author: Anthony G. Basile blueness AT gentoo DOT org
AuthorDate: Sat Jun 7 11:56:18 2014 +
Commit: Anthony G. Basile blueness AT gentoo DOT org
CommitDate: Sat Jun 7 11:57:10 2014 +
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=962b3194
src{fix-gnustack.c,paxctl-ng.c}: portable error reporting
---
configure.ac | 2 +-
src/fix-gnustack.c | 22 +++---
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; iphnum; ++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(WX 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,