1 |
commit: f34f9699a8c53dbde55af287281628cca743639a |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Jun 7 11:56:18 2014 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jun 7 14:24:24 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=f34f9699 |
7 |
|
8 |
src{fix-gnustack.c,paxctl-ng.c}: portable error reporting |
9 |
|
10 |
--- |
11 |
configure.ac | 2 +- |
12 |
src/fix-gnustack.c | 22 +++++++++++----------- |
13 |
src/paxctl-ng.c | 4 ++-- |
14 |
3 files changed, 14 insertions(+), 14 deletions(-) |
15 |
|
16 |
diff --git a/configure.ac b/configure.ac |
17 |
index 541f925..a1b0c33 100644 |
18 |
--- a/configure.ac |
19 |
+++ b/configure.ac |
20 |
@@ -44,7 +44,7 @@ AC_PROG_SED |
21 |
|
22 |
# Checks for header files. |
23 |
AC_CHECK_HEADERS( |
24 |
- [errno.h error.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \ |
25 |
+ [errno.h err.h fcntl.h gelf.h libgen.h stdio.h stdlib.h string.h \ |
26 |
sys/mman.h sys/stat.h sys/types.h unistd.h], |
27 |
[], |
28 |
[AC_MSG_ERROR(["Missing necessary header"])] |
29 |
|
30 |
diff --git a/src/fix-gnustack.c b/src/fix-gnustack.c |
31 |
index 0d6ecc1..59e10be 100644 |
32 |
--- a/src/fix-gnustack.c |
33 |
+++ b/src/fix-gnustack.c |
34 |
@@ -19,7 +19,7 @@ |
35 |
#include <stdio.h> |
36 |
#include <stdlib.h> |
37 |
#include <string.h> |
38 |
-#include <error.h> |
39 |
+#include <err.h> |
40 |
#include <libgen.h> |
41 |
|
42 |
#include <gelf.h> |
43 |
@@ -58,7 +58,7 @@ parse_cmd_args( int c, char *v[], int *flagv ) |
44 |
int i, oc; |
45 |
|
46 |
if((c != 2)&&(c != 3)) |
47 |
- error(EXIT_FAILURE, 0, "Usage: %s -f ELF | -h", v[0]); |
48 |
+ errx(EXIT_FAILURE, "Usage: %s -f ELF | -h", v[0]); |
49 |
|
50 |
*flagv = 0 ; |
51 |
while((oc = getopt(c, v,":fh")) != -1) |
52 |
@@ -72,7 +72,7 @@ parse_cmd_args( int c, char *v[], int *flagv ) |
53 |
break; |
54 |
case '?': |
55 |
default: |
56 |
- error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; |
57 |
+ errx(EXIT_FAILURE, "option -%c is invalid: ignored.", optopt ) ; |
58 |
} |
59 |
|
60 |
return v[optind] ; |
61 |
@@ -93,31 +93,31 @@ main( int argc, char *argv[]) |
62 |
f_name = parse_cmd_args(argc, argv, &flagv); |
63 |
|
64 |
if(elf_version(EV_CURRENT) == EV_NONE) |
65 |
- error(EXIT_FAILURE, 0, "Library out of date."); |
66 |
+ errx(EXIT_FAILURE, "Library out of date."); |
67 |
|
68 |
if(flagv) |
69 |
{ |
70 |
if((fd = open(f_name, O_RDWR)) < 0) |
71 |
- error(EXIT_FAILURE, 0, "open() fail."); |
72 |
+ errx(EXIT_FAILURE, "open() fail."); |
73 |
if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL) |
74 |
- error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno())); |
75 |
+ errx(EXIT_FAILURE, "elf_begin() fail: %s", elf_errmsg(elf_errno())); |
76 |
} |
77 |
else |
78 |
{ |
79 |
if((fd = open(f_name, O_RDONLY)) < 0) |
80 |
- error(EXIT_FAILURE, 0, "open() fail."); |
81 |
+ errx(EXIT_FAILURE, "open() fail."); |
82 |
if((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) |
83 |
- error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno())); |
84 |
+ errx(EXIT_FAILURE, "elf_begin() fail: %s", elf_errmsg(elf_errno())); |
85 |
} |
86 |
|
87 |
if(elf_kind(elf) != ELF_K_ELF) |
88 |
- error(EXIT_FAILURE, 0, "elf_kind() fail: this is not an elf file."); |
89 |
+ errx(EXIT_FAILURE, "elf_kind() fail: this is not an elf file."); |
90 |
|
91 |
elf_getphdrnum(elf, &phnum); |
92 |
for(i=0; i<phnum; ++i) |
93 |
{ |
94 |
if(gelf_getphdr(elf, i, &phdr) != &phdr) |
95 |
- error(EXIT_FAILURE, 0, "gelf_getphdr(): %s", elf_errmsg(elf_errno())); |
96 |
+ errx(EXIT_FAILURE, "gelf_getphdr(): %s", elf_errmsg(elf_errno())); |
97 |
|
98 |
if(phdr.p_type == PT_GNU_STACK) |
99 |
{ |
100 |
@@ -132,7 +132,7 @@ main( int argc, char *argv[]) |
101 |
printf("W&X FOUND: X flag removed\n"); |
102 |
phdr.p_flags ^= PF_X; |
103 |
if(!gelf_update_phdr(elf, i, &phdr)) |
104 |
- error(EXIT_FAILURE, 0, "gelf_update_phdr(): %s", elf_errmsg(elf_errno())); |
105 |
+ errx(EXIT_FAILURE, "gelf_update_phdr(): %s", elf_errmsg(elf_errno())); |
106 |
} |
107 |
} |
108 |
} |
109 |
|
110 |
diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c |
111 |
index 8071d50..d340a43 100644 |
112 |
--- a/src/paxctl-ng.c |
113 |
+++ b/src/paxctl-ng.c |
114 |
@@ -20,7 +20,7 @@ |
115 |
#include <stdint.h> |
116 |
#include <stdlib.h> |
117 |
#include <string.h> |
118 |
-#include <error.h> |
119 |
+#include <err.h> |
120 |
#include <libgen.h> |
121 |
#include <sys/types.h> |
122 |
#include <sys/stat.h> |
123 |
@@ -257,7 +257,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *c |
124 |
break; |
125 |
case '?': |
126 |
default: |
127 |
- error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; |
128 |
+ errx(EXIT_FAILURE, "option -%c is invalid: ignored.", optopt ) ; |
129 |
} |
130 |
} |