diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-28 23:31:54 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-28 23:31:54 +0000 |
commit | d52f45a484fc7fc049ab40db9adc6ead7ea9b122 (patch) | |
tree | 2a57564b8917a983365c765d4daa83032d9f0a17 /libbb | |
parent | 2803d256e9decd450b955c2846bf945db72bb79e (diff) | |
download | busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.tar.gz busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.tar.bz2 busybox-w32-d52f45a484fc7fc049ab40db9adc6ead7ea9b122.zip |
- pull from busybox_scratch: r15829:15850
Various fixes, cleanups and shrinkage:
saves 952 Bytes:
text data bss dec hex filename
1087742 15853 790632 1894227 1ce753 ../busybox/busybox.old
1086790 15853 790632 1893275 1ce39b busybox
via:
# scripts/bloat-o-meter ../busybox/busybox_unstripped.old busybox_unstripped
function old new delta
ipcrm_main 756 822 +66
getval - 61 +61
maybe_set_utc - 40 +40
udhcpc_main 2896 2912 +16
md5_hash_block 428 437 +9
opt 8 16 +8
qgravechar 106 110 +4
make_bitmap 292 295 +3
inflate_unzip 2056 2059 +3
add_partition 1412 1414 +2
__parsespent 156 158 +2
qrealloc 41 42 +1
format - 1 +1
catv_main 313 314 +1
watch_main 293 292 -1
varunset 81 80 -1
part 1 - -1
check_if_skip 837 836 -1
start_stop_daemon_main 840 837 -3
create_lost_and_found 175 172 -3
supress_non_delimited_lines 4 - -4
static.l 4 - -4
static.c 5 1 -4
bsd_sum_file 237 233 -4
eval2 338 332 -6
arithmetic_common 166 158 -8
cmpfunc 22 5 -17
cksum_main 294 275 -19
cmp_main 465 439 -26
dd_main 1535 1508 -27
rmmod_main 376 333 -43
cut_file 727 644 -83
ipcs_main 3809 3721 -88
cut_main 722 614 -108
date_main 1443 1263 -180
remove_ids 222 - -222
------------------------------------------------------------------------------
(add/remove: 3/4 grow/shrink: 11/18 up/down: 217/-853) Total: -636 bytes
git-svn-id: svn://busybox.net/trunk/busybox@16009 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xfuncs.c | 133 |
1 files changed, 70 insertions, 63 deletions
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 4d81fdc28..b2b53a712 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -16,8 +16,12 @@ | |||
16 | * succeeded. */ | 16 | * succeeded. */ |
17 | 17 | ||
18 | #ifndef DMALLOC | 18 | #ifndef DMALLOC |
19 | /* dmalloc provides variants of these that do abort() on failure. | ||
20 | * Since dmalloc's prototypes overwrite the impls here as they are | ||
21 | * included after these prototypes in libbb.h, all is well. | ||
22 | */ | ||
19 | #ifdef L_xmalloc | 23 | #ifdef L_xmalloc |
20 | // Die if we can't allocate size bytes of memory. | 24 | /* Die if we can't allocate size bytes of memory. */ |
21 | void *xmalloc(size_t size) | 25 | void *xmalloc(size_t size) |
22 | { | 26 | { |
23 | void *ptr = malloc(size); | 27 | void *ptr = malloc(size); |
@@ -28,9 +32,9 @@ void *xmalloc(size_t size) | |||
28 | #endif | 32 | #endif |
29 | 33 | ||
30 | #ifdef L_xrealloc | 34 | #ifdef L_xrealloc |
31 | // Die if we can't resize previously allocated memory. (This returns a pointer | 35 | /* Die if we can't resize previously allocated memory. (This returns a pointer |
32 | // to the new memory, which may or may not be the same as the old memory. | 36 | * to the new memory, which may or may not be the same as the old memory. |
33 | // It'll copy the contents to a new chunk and free the old one if necessary.) | 37 | * It'll copy the contents to a new chunk and free the old one if necessary.) */ |
34 | void *xrealloc(void *ptr, size_t size) | 38 | void *xrealloc(void *ptr, size_t size) |
35 | { | 39 | { |
36 | ptr = realloc(ptr, size); | 40 | ptr = realloc(ptr, size); |
@@ -39,9 +43,11 @@ void *xrealloc(void *ptr, size_t size) | |||
39 | return ptr; | 43 | return ptr; |
40 | } | 44 | } |
41 | #endif | 45 | #endif |
46 | #endif /* DMALLOC */ | ||
47 | |||
42 | 48 | ||
43 | #ifdef L_xzalloc | 49 | #ifdef L_xzalloc |
44 | // Die if we can't allocate and zero size bytes of memory. | 50 | /* Die if we can't allocate and zero size bytes of memory. */ |
45 | void *xzalloc(size_t size) | 51 | void *xzalloc(size_t size) |
46 | { | 52 | { |
47 | void *ptr = xmalloc(size); | 53 | void *ptr = xmalloc(size); |
@@ -50,10 +56,8 @@ void *xzalloc(size_t size) | |||
50 | } | 56 | } |
51 | #endif | 57 | #endif |
52 | 58 | ||
53 | #endif /* DMALLOC */ | ||
54 | |||
55 | #ifdef L_xstrdup | 59 | #ifdef L_xstrdup |
56 | // Die if we can't copy a string to freshly allocated memory. | 60 | /* Die if we can't copy a string to freshly allocated memory. */ |
57 | char * xstrdup(const char *s) | 61 | char * xstrdup(const char *s) |
58 | { | 62 | { |
59 | char *t; | 63 | char *t; |
@@ -71,8 +75,9 @@ char * xstrdup(const char *s) | |||
71 | #endif | 75 | #endif |
72 | 76 | ||
73 | #ifdef L_xstrndup | 77 | #ifdef L_xstrndup |
74 | // Die if we can't allocate n+1 bytes (space for the null terminator) and copy | 78 | /* Die if we can't allocate n+1 bytes (space for the null terminator) and copy |
75 | // the (possibly truncated to length n) string into it. | 79 | * the (possibly truncated to length n) string into it. |
80 | */ | ||
76 | char * xstrndup(const char *s, int n) | 81 | char * xstrndup(const char *s, int n) |
77 | { | 82 | { |
78 | char *t; | 83 | char *t; |
@@ -87,8 +92,9 @@ char * xstrndup(const char *s, int n) | |||
87 | #endif | 92 | #endif |
88 | 93 | ||
89 | #ifdef L_xfopen | 94 | #ifdef L_xfopen |
90 | // Die if we can't open a file and return a FILE * to it. | 95 | /* Die if we can't open a file and return a FILE * to it. |
91 | // Notice we haven't got xfread(), This is for use with fscanf() and friends. | 96 | * Notice we haven't got xfread(), This is for use with fscanf() and friends. |
97 | */ | ||
92 | FILE *xfopen(const char *path, const char *mode) | 98 | FILE *xfopen(const char *path, const char *mode) |
93 | { | 99 | { |
94 | FILE *fp; | 100 | FILE *fp; |
@@ -99,7 +105,7 @@ FILE *xfopen(const char *path, const char *mode) | |||
99 | #endif | 105 | #endif |
100 | 106 | ||
101 | #ifdef L_xopen | 107 | #ifdef L_xopen |
102 | // Die if we can't open an existing file and return an fd. | 108 | /* Die if we can't open an existing file and return an fd. */ |
103 | int xopen(const char *pathname, int flags) | 109 | int xopen(const char *pathname, int flags) |
104 | { | 110 | { |
105 | if (ENABLE_DEBUG && (flags && O_CREAT)) | 111 | if (ENABLE_DEBUG && (flags && O_CREAT)) |
@@ -110,7 +116,7 @@ int xopen(const char *pathname, int flags) | |||
110 | #endif | 116 | #endif |
111 | 117 | ||
112 | #ifdef L_xopen3 | 118 | #ifdef L_xopen3 |
113 | // Die if we can't open a new file and return an fd. | 119 | /* Die if we can't open a new file and return an fd. */ |
114 | int xopen3(const char *pathname, int flags, int mode) | 120 | int xopen3(const char *pathname, int flags, int mode) |
115 | { | 121 | { |
116 | int ret; | 122 | int ret; |
@@ -124,7 +130,7 @@ int xopen3(const char *pathname, int flags, int mode) | |||
124 | #endif | 130 | #endif |
125 | 131 | ||
126 | #ifdef L_xread | 132 | #ifdef L_xread |
127 | // Die with an error message if we can't read the entire buffer. | 133 | /* Die with an error message if we can't read the entire buffer. */ |
128 | void xread(int fd, void *buf, size_t count) | 134 | void xread(int fd, void *buf, size_t count) |
129 | { | 135 | { |
130 | while (count) { | 136 | while (count) { |
@@ -139,7 +145,7 @@ void xread(int fd, void *buf, size_t count) | |||
139 | #endif | 145 | #endif |
140 | 146 | ||
141 | #ifdef L_xwrite | 147 | #ifdef L_xwrite |
142 | // Die with an error message if we can't write the entire buffer. | 148 | /* Die with an error message if we can't write the entire buffer. */ |
143 | void xwrite(int fd, void *buf, size_t count) | 149 | void xwrite(int fd, void *buf, size_t count) |
144 | { | 150 | { |
145 | while (count) { | 151 | while (count) { |
@@ -154,7 +160,7 @@ void xwrite(int fd, void *buf, size_t count) | |||
154 | #endif | 160 | #endif |
155 | 161 | ||
156 | #ifdef L_xlseek | 162 | #ifdef L_xlseek |
157 | // Die with an error message if we can't lseek to the right spot. | 163 | /* Die with an error message if we can't lseek to the right spot. */ |
158 | void xlseek(int fd, off_t offset, int whence) | 164 | void xlseek(int fd, off_t offset, int whence) |
159 | { | 165 | { |
160 | if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek"); | 166 | if (offset != lseek(fd, offset, whence)) bb_error_msg_and_die("lseek"); |
@@ -162,7 +168,7 @@ void xlseek(int fd, off_t offset, int whence) | |||
162 | #endif | 168 | #endif |
163 | 169 | ||
164 | #ifdef L_xread_char | 170 | #ifdef L_xread_char |
165 | // Die with an error message if we can't read one character. | 171 | /* Die with an error message if we can't read one character. */ |
166 | unsigned char xread_char(int fd) | 172 | unsigned char xread_char(int fd) |
167 | { | 173 | { |
168 | char tmp; | 174 | char tmp; |
@@ -174,7 +180,7 @@ unsigned char xread_char(int fd) | |||
174 | #endif | 180 | #endif |
175 | 181 | ||
176 | #ifdef L_xferror | 182 | #ifdef L_xferror |
177 | // Die with supplied error message if this FILE * has ferror set. | 183 | /* Die with supplied error message if this FILE * has ferror set. */ |
178 | void xferror(FILE *fp, const char *fn) | 184 | void xferror(FILE *fp, const char *fn) |
179 | { | 185 | { |
180 | if (ferror(fp)) { | 186 | if (ferror(fp)) { |
@@ -184,7 +190,7 @@ void xferror(FILE *fp, const char *fn) | |||
184 | #endif | 190 | #endif |
185 | 191 | ||
186 | #ifdef L_xferror_stdout | 192 | #ifdef L_xferror_stdout |
187 | // Die with an error message if stdout has ferror set. | 193 | /* Die with an error message if stdout has ferror set. */ |
188 | void xferror_stdout(void) | 194 | void xferror_stdout(void) |
189 | { | 195 | { |
190 | xferror(stdout, bb_msg_standard_output); | 196 | xferror(stdout, bb_msg_standard_output); |
@@ -192,7 +198,7 @@ void xferror_stdout(void) | |||
192 | #endif | 198 | #endif |
193 | 199 | ||
194 | #ifdef L_xfflush_stdout | 200 | #ifdef L_xfflush_stdout |
195 | // Die with an error message if we have trouble flushing stdout. | 201 | /* Die with an error message if we have trouble flushing stdout. */ |
196 | void xfflush_stdout(void) | 202 | void xfflush_stdout(void) |
197 | { | 203 | { |
198 | if (fflush(stdout)) { | 204 | if (fflush(stdout)) { |
@@ -202,24 +208,25 @@ void xfflush_stdout(void) | |||
202 | #endif | 208 | #endif |
203 | 209 | ||
204 | #ifdef L_spawn | 210 | #ifdef L_spawn |
205 | // This does a fork/exec in one call, using vfork(). Return PID of new child, | 211 | /* This does a fork/exec in one call, using vfork(). Return PID of new child, |
206 | // -1 for failure. Runs argv[0], searching path if that has no / in it. | 212 | * -1 for failure. Runs argv[0], searching path if that has no / in it. |
213 | */ | ||
207 | pid_t spawn(char **argv) | 214 | pid_t spawn(char **argv) |
208 | { | 215 | { |
209 | static int failed; | 216 | static int failed; |
210 | pid_t pid; | 217 | pid_t pid; |
211 | void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0; | 218 | void *app = ENABLE_FEATURE_SH_STANDALONE_SHELL ? find_applet_by_name(argv[0]) : 0; |
212 | 219 | ||
213 | // Be nice to nommu machines. | 220 | /* Be nice to nommu machines. */ |
214 | failed = 0; | 221 | failed = 0; |
215 | pid = vfork(); | 222 | pid = vfork(); |
216 | if (pid < 0) return pid; | 223 | if (pid < 0) return pid; |
217 | if (!pid) { | 224 | if (!pid) { |
218 | execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv); | 225 | execvp(app ? CONFIG_BUSYBOX_EXEC_PATH : *argv, argv); |
219 | 226 | ||
220 | // We're sharing a stack with blocked parent, let parent know we failed | 227 | /* We're sharing a stack with blocked parent, let parent know we failed |
221 | // and then exit to unblock parent (but don't run atexit() stuff, which | 228 | * and then exit to unblock parent (but don't run atexit() stuff, which |
222 | // would screw up parent.) | 229 | would screw up parent.) */ |
223 | 230 | ||
224 | failed = -1; | 231 | failed = -1; |
225 | _exit(0); | 232 | _exit(0); |
@@ -229,7 +236,7 @@ pid_t spawn(char **argv) | |||
229 | #endif | 236 | #endif |
230 | 237 | ||
231 | #ifdef L_xspawn | 238 | #ifdef L_xspawn |
232 | // Die with an error message if we can't spawn a child process. | 239 | /* Die with an error message if we can't spawn a child process. */ |
233 | pid_t xspawn(char **argv) | 240 | pid_t xspawn(char **argv) |
234 | { | 241 | { |
235 | pid_t pid = spawn(argv); | 242 | pid_t pid = spawn(argv); |
@@ -239,7 +246,7 @@ pid_t xspawn(char **argv) | |||
239 | #endif | 246 | #endif |
240 | 247 | ||
241 | #ifdef L_wait4 | 248 | #ifdef L_wait4 |
242 | // Wait for the specified child PID to exit, returning child's error return. | 249 | /* Wait for the specified child PID to exit, returning child's error return. */ |
243 | int wait4pid(int pid) | 250 | int wait4pid(int pid) |
244 | { | 251 | { |
245 | int status; | 252 | int status; |
@@ -252,9 +259,9 @@ int wait4pid(int pid) | |||
252 | #endif | 259 | #endif |
253 | 260 | ||
254 | #ifdef L_itoa | 261 | #ifdef L_itoa |
255 | // Convert unsigned integer to ascii, writing into supplied buffer. A | 262 | /* Convert unsigned integer to ascii, writing into supplied buffer. A |
256 | // truncated result is always null terminated (unless buflen is 0), and | 263 | * truncated result is always null terminated (unless buflen is 0), and |
257 | // contains the first few digits of the result ala strncpy. | 264 | * contains the first few digits of the result ala strncpy. */ |
258 | void utoa_to_buf(unsigned n, char *buf, unsigned buflen) | 265 | void utoa_to_buf(unsigned n, char *buf, unsigned buflen) |
259 | { | 266 | { |
260 | int i, out = 0; | 267 | int i, out = 0; |
@@ -272,7 +279,7 @@ void utoa_to_buf(unsigned n, char *buf, unsigned buflen) | |||
272 | } | 279 | } |
273 | } | 280 | } |
274 | 281 | ||
275 | // Convert signed integer to ascii, like utoa_to_buf() | 282 | /* Convert signed integer to ascii, like utoa_to_buf() */ |
276 | void itoa_to_buf(int n, char *buf, unsigned buflen) | 283 | void itoa_to_buf(int n, char *buf, unsigned buflen) |
277 | { | 284 | { |
278 | if (buflen && n<0) { | 285 | if (buflen && n<0) { |
@@ -283,16 +290,16 @@ void itoa_to_buf(int n, char *buf, unsigned buflen) | |||
283 | utoa_to_buf((unsigned)n, buf, buflen); | 290 | utoa_to_buf((unsigned)n, buf, buflen); |
284 | } | 291 | } |
285 | 292 | ||
286 | // The following two functions use a static buffer, so calling either one a | 293 | /* The following two functions use a static buffer, so calling either one a |
287 | // second time will overwrite previous results. | 294 | * second time will overwrite previous results. |
288 | // | 295 | * |
289 | // The largest 32 bit integer is -2 billion plus null terminator, or 12 bytes. | 296 | * The largest 32 bit integer is -2 billion plus null terminator, or 12 bytes. |
290 | // Int should always be 32 bits on any remotely Unix-like system, see | 297 | * Int should always be 32 bits on any remotely Unix-like system, see |
291 | // http://www.unix.org/whitepapers/64bit.html for the reasons why. | 298 | * http://www.unix.org/whitepapers/64bit.html for the reasons why. |
292 | 299 | */ | |
293 | static char local_buf[12]; | 300 | static char local_buf[12]; |
294 | 301 | ||
295 | // Convert unsigned integer to ascii using a static buffer (returned). | 302 | /* Convert unsigned integer to ascii using a static buffer (returned). */ |
296 | char *utoa(unsigned n) | 303 | char *utoa(unsigned n) |
297 | { | 304 | { |
298 | utoa_to_buf(n, local_buf, sizeof(local_buf)); | 305 | utoa_to_buf(n, local_buf, sizeof(local_buf)); |
@@ -300,7 +307,7 @@ char *utoa(unsigned n) | |||
300 | return local_buf; | 307 | return local_buf; |
301 | } | 308 | } |
302 | 309 | ||
303 | // Convert signed integer to ascii using a static buffer (returned). | 310 | /* Convert signed integer to ascii using a static buffer (returned). */ |
304 | char *itoa(int n) | 311 | char *itoa(int n) |
305 | { | 312 | { |
306 | itoa_to_buf(n, local_buf, sizeof(local_buf)); | 313 | itoa_to_buf(n, local_buf, sizeof(local_buf)); |
@@ -310,15 +317,15 @@ char *itoa(int n) | |||
310 | #endif | 317 | #endif |
311 | 318 | ||
312 | #ifdef L_setuid | 319 | #ifdef L_setuid |
313 | // Die with an error message if we can't set gid. (Because resource limits may | 320 | /* Die with an error message if we can't set gid. (Because resource limits may |
314 | // limit this user to a given number of processes, and if that fills up the | 321 | * limit this user to a given number of processes, and if that fills up the |
315 | // setgid() will fail and we'll _still_be_root_, which is bad.) | 322 | * setgid() will fail and we'll _still_be_root_, which is bad.) */ |
316 | void xsetgid(gid_t gid) | 323 | void xsetgid(gid_t gid) |
317 | { | 324 | { |
318 | if (setgid(gid)) bb_error_msg_and_die("setgid"); | 325 | if (setgid(gid)) bb_error_msg_and_die("setgid"); |
319 | } | 326 | } |
320 | 327 | ||
321 | // Die with an error message if we cant' set uid. (See xsetgid() for why.) | 328 | /* Die with an error message if we cant' set uid. (See xsetgid() for why.) */ |
322 | void xsetuid(uid_t uid) | 329 | void xsetuid(uid_t uid) |
323 | { | 330 | { |
324 | if (setuid(uid)) bb_error_msg_and_die("setuid"); | 331 | if (setuid(uid)) bb_error_msg_and_die("setuid"); |
@@ -326,31 +333,31 @@ void xsetuid(uid_t uid) | |||
326 | #endif | 333 | #endif |
327 | 334 | ||
328 | #ifdef L_fdlength | 335 | #ifdef L_fdlength |
329 | // Return how long the file at fd is, if there's any way to determine it. | 336 | /* Return how long the file at fd is, if there's any way to determine it. */ |
330 | off_t fdlength(int fd) | 337 | off_t fdlength(int fd) |
331 | { | 338 | { |
332 | off_t bottom = 0, top = 0, pos; | 339 | off_t bottom = 0, top = 0, pos; |
333 | long size; | 340 | long size; |
334 | 341 | ||
335 | // If the ioctl works for this, return it. | 342 | /* If the ioctl works for this, return it. */ |
336 | 343 | ||
337 | if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512; | 344 | if (ioctl(fd, BLKGETSIZE, &size) >= 0) return size*512; |
338 | 345 | ||
339 | // If not, do a binary search for the last location we can read. (Some | 346 | /* If not, do a binary search for the last location we can read. (Some |
340 | // block devices don't do BLKGETSIZE right.) | 347 | * block devices don't do BLKGETSIZE right.) */ |
341 | 348 | ||
342 | do { | 349 | do { |
343 | char temp; | 350 | char temp; |
344 | 351 | ||
345 | pos = bottom + (top - bottom) / 2;; | 352 | pos = bottom + (top - bottom) / 2;; |
346 | 353 | ||
347 | // If we can read from the current location, it's bigger. | 354 | /* If we can read from the current location, it's bigger. */ |
348 | 355 | ||
349 | if (lseek(fd, pos, 0)>=0 && safe_read(fd, &temp, 1)==1) { | 356 | if (lseek(fd, pos, 0)>=0 && safe_read(fd, &temp, 1)==1) { |
350 | if (bottom == top) bottom = top = (top+1) * 2; | 357 | if (bottom == top) bottom = top = (top+1) * 2; |
351 | else bottom = pos; | 358 | else bottom = pos; |
352 | 359 | ||
353 | // If we can't, it's smaller. | 360 | /* If we can't, it's smaller. */ |
354 | 361 | ||
355 | } else { | 362 | } else { |
356 | if (bottom == top) { | 363 | if (bottom == top) { |
@@ -366,8 +373,8 @@ off_t fdlength(int fd) | |||
366 | #endif | 373 | #endif |
367 | 374 | ||
368 | #ifdef L_xasprintf | 375 | #ifdef L_xasprintf |
369 | // Die with an error message if we can't malloc() enough space and do an | 376 | /* Die with an error message if we can't malloc() enough space and do an |
370 | // sprintf() into that space. | 377 | * sprintf() into that space. */ |
371 | char *xasprintf(const char *format, ...) | 378 | char *xasprintf(const char *format, ...) |
372 | { | 379 | { |
373 | va_list p; | 380 | va_list p; |
@@ -396,8 +403,8 @@ char *xasprintf(const char *format, ...) | |||
396 | #endif | 403 | #endif |
397 | 404 | ||
398 | #ifdef L_xprint_and_close_file | 405 | #ifdef L_xprint_and_close_file |
399 | // Die with an error message if we can't copy an entire FILE * to stdout, then | 406 | /* Die with an error message if we can't copy an entire FILE * to stdout, then |
400 | // close that file. | 407 | * close that file. */ |
401 | void xprint_and_close_file(FILE *file) | 408 | void xprint_and_close_file(FILE *file) |
402 | { | 409 | { |
403 | // copyfd outputs error messages for us. | 410 | // copyfd outputs error messages for us. |
@@ -408,7 +415,7 @@ void xprint_and_close_file(FILE *file) | |||
408 | #endif | 415 | #endif |
409 | 416 | ||
410 | #ifdef L_xchdir | 417 | #ifdef L_xchdir |
411 | // Die if we can't chdir to a new path. | 418 | /* Die if we can't chdir to a new path. */ |
412 | void xchdir(const char *path) | 419 | void xchdir(const char *path) |
413 | { | 420 | { |
414 | if (chdir(path)) | 421 | if (chdir(path)) |
@@ -417,7 +424,7 @@ void xchdir(const char *path) | |||
417 | #endif | 424 | #endif |
418 | 425 | ||
419 | #ifdef L_warn_opendir | 426 | #ifdef L_warn_opendir |
420 | // Print a warning message if opendir() fails, but don't die. | 427 | /* Print a warning message if opendir() fails, but don't die. */ |
421 | DIR *warn_opendir(const char *path) | 428 | DIR *warn_opendir(const char *path) |
422 | { | 429 | { |
423 | DIR *dp; | 430 | DIR *dp; |
@@ -431,7 +438,7 @@ DIR *warn_opendir(const char *path) | |||
431 | #endif | 438 | #endif |
432 | 439 | ||
433 | #ifdef L_xopendir | 440 | #ifdef L_xopendir |
434 | // Die with an error message if opendir() fails. | 441 | /* Die with an error message if opendir() fails. */ |
435 | DIR *xopendir(const char *path) | 442 | DIR *xopendir(const char *path) |
436 | { | 443 | { |
437 | DIR *dp; | 444 | DIR *dp; |
@@ -444,7 +451,7 @@ DIR *xopendir(const char *path) | |||
444 | 451 | ||
445 | #ifdef L_xdaemon | 452 | #ifdef L_xdaemon |
446 | #ifndef BB_NOMMU | 453 | #ifndef BB_NOMMU |
447 | // Die with an error message if we can't daemonize. | 454 | /* Die with an error message if we can't daemonize. */ |
448 | void xdaemon(int nochdir, int noclose) | 455 | void xdaemon(int nochdir, int noclose) |
449 | { | 456 | { |
450 | if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon"); | 457 | if (daemon(nochdir, noclose)) bb_perror_msg_and_die("daemon"); |
@@ -453,7 +460,7 @@ void xdaemon(int nochdir, int noclose) | |||
453 | #endif | 460 | #endif |
454 | 461 | ||
455 | #ifdef L_xsocket | 462 | #ifdef L_xsocket |
456 | // Die with an error message if we can't open a new socket. | 463 | /* Die with an error message if we can't open a new socket. */ |
457 | int xsocket(int domain, int type, int protocol) | 464 | int xsocket(int domain, int type, int protocol) |
458 | { | 465 | { |
459 | int r = socket(domain, type, protocol); | 466 | int r = socket(domain, type, protocol); |
@@ -465,7 +472,7 @@ int xsocket(int domain, int type, int protocol) | |||
465 | #endif | 472 | #endif |
466 | 473 | ||
467 | #ifdef L_xbind | 474 | #ifdef L_xbind |
468 | // Die with an error message if we can't bind a socket to an address. | 475 | /* Die with an error message if we can't bind a socket to an address. */ |
469 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) | 476 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) |
470 | { | 477 | { |
471 | if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind"); | 478 | if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind"); |
@@ -473,7 +480,7 @@ void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) | |||
473 | #endif | 480 | #endif |
474 | 481 | ||
475 | #ifdef L_xlisten | 482 | #ifdef L_xlisten |
476 | // Die with an error message if we can't listen for connections on a socket. | 483 | /* Die with an error message if we can't listen for connections on a socket. */ |
477 | void xlisten(int s, int backlog) | 484 | void xlisten(int s, int backlog) |
478 | { | 485 | { |
479 | if (listen(s, backlog)) bb_perror_msg_and_die("listen"); | 486 | if (listen(s, backlog)) bb_perror_msg_and_die("listen"); |