summaryrefslogtreecommitdiff
blob: c359f4c9062ff0f5e2c7a6606dae3cccb7aaf503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
From 3bbf0d863131ce650928460bf1222617e7e68094 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 24 Jan 2012 00:33:57 -0500
Subject: [PATCH 1/5] include error.h for error() and friends

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 include/c.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/c.h b/include/c.h
index 2be7495..747e4e3 100644
--- a/include/c.h
+++ b/include/c.h
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
+#include <error.h>
 
 /*
  * Compiler specific stuff
-- 
1.7.8.3

From eee0a65a45713a8e6efcfd94dbeabd33f6cf8a3a Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 24 Jan 2012 00:36:02 -0500
Subject: [PATCH 2/5] watch: include sys/wait.h for waitpid

Fixes build warning:
	watch.c:682:3: warning: implicit declaration of
		function 'waitpid' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 watch.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/watch.c b/watch.c
index 4a2646b..0bb6239 100644
--- a/watch.c
+++ b/watch.c
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
+#include <sys/wait.h>
 #include <termios.h>
 #include <termios.h>
 #include <time.h>
-- 
1.7.8.3

From 4191f4598701b7d76df4be0506f06f15d97b9a64 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 24 Jan 2012 00:39:49 -0500
Subject: [PATCH 3/5] use helpers from c.h

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 |    8 ++++----
 proc/sig.c       |    3 ++-
 skill.c          |    2 +-
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/xalloc.h b/include/xalloc.h
index bd02c75..37bf0ef 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -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;
 }
 
diff --git a/proc/sig.c b/proc/sig.c
index 1137fef..b83e645 100644
--- a/proc/sig.c
+++ b/proc/sig.c
@@ -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/skill.c b/skill.c
index de3ccb9..078624d 100644
--- 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);
-- 
1.7.8.3

From b5de7d14e1db889c83dc45ae275652aa042c359c Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 24 Jan 2012 00:41:25 -0500
Subject: [PATCH 4/5] proc: pull in ctype.h where needed

Fix the build warnings:

sig.c:227:5: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration]
sig.c:231:3: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 proc/sig.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/proc/sig.c b/proc/sig.c
index b83e645..b427e01 100644
--- a/proc/sig.c
+++ b/proc/sig.c
@@ -8,6 +8,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU Library General Public License for more details.
  */
+#include <ctype.h>
 #include <signal.h>
 #include <string.h>
 #include <stdio.h>
-- 
1.7.8.3

From 4abea5e70d391a363c2af9a6405e375081cb10b2 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 24 Jan 2012 00:43:35 -0500
Subject: [PATCH 5/5] ps: include error.h

This code currently uses error_at_line() from error.h, so pull it in.
Long term, this might get moved to c.h as a local helper on err.h,
but I have no idea.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 ps/global.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/ps/global.c b/ps/global.c
index 22cf3ef..5bddb8c 100644
--- a/ps/global.c
+++ b/ps/global.c
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
+#include <error.h>
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
-- 
1.7.8.3