diff options
author | Ron Yorston <rmy@pobox.com> | 2019-08-16 09:42:39 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-08-16 09:45:21 +0100 |
commit | 517cf74f6265ec4308b790b637b3f9778cbdc6e0 (patch) | |
tree | be9337069b60ca1bb03565d8575bacfc71181003 /libbb/xfuncs_printf.c | |
parent | ae65dc37bcc9b1d9cef0b111131c79dc4ba1bf51 (diff) | |
parent | ac78f2ac96b3efd6551a08e7dc609efa1fb69481 (diff) | |
download | busybox-w32-517cf74f6265ec4308b790b637b3f9778cbdc6e0.tar.gz busybox-w32-517cf74f6265ec4308b790b637b3f9778cbdc6e0.tar.bz2 busybox-w32-517cf74f6265ec4308b790b637b3f9778cbdc6e0.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/xfuncs_printf.c')
-rw-r--r-- | libbb/xfuncs_printf.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index a0db2b86e..cfe062a47 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | void FAST_FUNC bb_die_memory_exhausted(void) | 28 | void FAST_FUNC bb_die_memory_exhausted(void) |
29 | { | 29 | { |
30 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 30 | bb_simple_error_msg_and_die(bb_msg_memory_exhausted); |
31 | } | 31 | } |
32 | 32 | ||
33 | #ifndef DMALLOC | 33 | #ifndef DMALLOC |
@@ -40,7 +40,7 @@ void* FAST_FUNC malloc_or_warn(size_t size) | |||
40 | { | 40 | { |
41 | void *ptr = malloc(size); | 41 | void *ptr = malloc(size); |
42 | if (ptr == NULL && size != 0) | 42 | if (ptr == NULL && size != 0) |
43 | bb_error_msg(bb_msg_memory_exhausted); | 43 | bb_simple_error_msg(bb_msg_memory_exhausted); |
44 | return ptr; | 44 | return ptr; |
45 | } | 45 | } |
46 | 46 | ||
@@ -97,7 +97,7 @@ char* FAST_FUNC xstrndup(const char *s, int n) | |||
97 | char *t; | 97 | char *t; |
98 | 98 | ||
99 | if (ENABLE_DEBUG && s == NULL) | 99 | if (ENABLE_DEBUG && s == NULL) |
100 | bb_error_msg_and_die("xstrndup bug"); | 100 | bb_simple_error_msg_and_die("xstrndup bug"); |
101 | 101 | ||
102 | /* We can just xmalloc(n+1) and strncpy into it, */ | 102 | /* We can just xmalloc(n+1) and strncpy into it, */ |
103 | /* but think about xstrndup("abc", 10000) wastage! */ | 103 | /* but think about xstrndup("abc", 10000) wastage! */ |
@@ -215,13 +215,13 @@ int FAST_FUNC rename_or_warn(const char *oldpath, const char *newpath) | |||
215 | void FAST_FUNC xpipe(int filedes[2]) | 215 | void FAST_FUNC xpipe(int filedes[2]) |
216 | { | 216 | { |
217 | if (pipe(filedes)) | 217 | if (pipe(filedes)) |
218 | bb_perror_msg_and_die("can't create pipe"); | 218 | bb_simple_perror_msg_and_die("can't create pipe"); |
219 | } | 219 | } |
220 | 220 | ||
221 | void FAST_FUNC xdup2(int from, int to) | 221 | void FAST_FUNC xdup2(int from, int to) |
222 | { | 222 | { |
223 | if (dup2(from, to) != to) | 223 | if (dup2(from, to) != to) |
224 | bb_perror_msg_and_die("can't duplicate file descriptor"); | 224 | bb_simple_perror_msg_and_die("can't duplicate file descriptor"); |
225 | // " %d to %d", from, to); | 225 | // " %d to %d", from, to); |
226 | } | 226 | } |
227 | 227 | ||
@@ -245,7 +245,7 @@ void FAST_FUNC xwrite(int fd, const void *buf, size_t count) | |||
245 | * or some writes succeeded, then we hit an error. | 245 | * or some writes succeeded, then we hit an error. |
246 | * In either case, errno is set. | 246 | * In either case, errno is set. |
247 | */ | 247 | */ |
248 | bb_perror_msg_and_die( | 248 | bb_simple_perror_msg_and_die( |
249 | size >= 0 ? "short write" : "write error" | 249 | size >= 0 ? "short write" : "write error" |
250 | ); | 250 | ); |
251 | } | 251 | } |
@@ -259,7 +259,7 @@ void FAST_FUNC xwrite_str(int fd, const char *str) | |||
259 | void FAST_FUNC xclose(int fd) | 259 | void FAST_FUNC xclose(int fd) |
260 | { | 260 | { |
261 | if (close(fd)) | 261 | if (close(fd)) |
262 | bb_perror_msg_and_die("close failed"); | 262 | bb_simple_perror_msg_and_die("close failed"); |
263 | } | 263 | } |
264 | 264 | ||
265 | // Die with an error message if we can't lseek to the right spot. | 265 | // Die with an error message if we can't lseek to the right spot. |
@@ -267,9 +267,7 @@ off_t FAST_FUNC xlseek(int fd, off_t offset, int whence) | |||
267 | { | 267 | { |
268 | off_t off = lseek(fd, offset, whence); | 268 | off_t off = lseek(fd, offset, whence); |
269 | if (off == (off_t)-1) { | 269 | if (off == (off_t)-1) { |
270 | if (whence == SEEK_SET) | 270 | bb_perror_msg_and_die("lseek(%"OFF_FMT"u, %d)", offset, whence); |
271 | bb_perror_msg_and_die("lseek(%"OFF_FMT"u)", offset); | ||
272 | bb_perror_msg_and_die("lseek"); | ||
273 | } | 271 | } |
274 | return off; | 272 | return off; |
275 | } | 273 | } |
@@ -384,23 +382,23 @@ void FAST_FUNC bb_unsetenv_and_free(char *var) | |||
384 | // setgid() will fail and we'll _still_be_root_, which is bad.) | 382 | // setgid() will fail and we'll _still_be_root_, which is bad.) |
385 | void FAST_FUNC xsetgid(gid_t gid) | 383 | void FAST_FUNC xsetgid(gid_t gid) |
386 | { | 384 | { |
387 | if (setgid(gid)) bb_perror_msg_and_die("setgid"); | 385 | if (setgid(gid)) bb_simple_perror_msg_and_die("setgid"); |
388 | } | 386 | } |
389 | 387 | ||
390 | // Die with an error message if we can't set uid. (See xsetgid() for why.) | 388 | // Die with an error message if we can't set uid. (See xsetgid() for why.) |
391 | void FAST_FUNC xsetuid(uid_t uid) | 389 | void FAST_FUNC xsetuid(uid_t uid) |
392 | { | 390 | { |
393 | if (setuid(uid)) bb_perror_msg_and_die("setuid"); | 391 | if (setuid(uid)) bb_simple_perror_msg_and_die("setuid"); |
394 | } | 392 | } |
395 | 393 | ||
396 | void FAST_FUNC xsetegid(gid_t egid) | 394 | void FAST_FUNC xsetegid(gid_t egid) |
397 | { | 395 | { |
398 | if (setegid(egid)) bb_perror_msg_and_die("setegid"); | 396 | if (setegid(egid)) bb_simple_perror_msg_and_die("setegid"); |
399 | } | 397 | } |
400 | 398 | ||
401 | void FAST_FUNC xseteuid(uid_t euid) | 399 | void FAST_FUNC xseteuid(uid_t euid) |
402 | { | 400 | { |
403 | if (seteuid(euid)) bb_perror_msg_and_die("seteuid"); | 401 | if (seteuid(euid)) bb_simple_perror_msg_and_die("seteuid"); |
404 | } | 402 | } |
405 | 403 | ||
406 | // Die if we can't chdir to a new path. | 404 | // Die if we can't chdir to a new path. |
@@ -413,7 +411,7 @@ void FAST_FUNC xchdir(const char *path) | |||
413 | void FAST_FUNC xfchdir(int fd) | 411 | void FAST_FUNC xfchdir(int fd) |
414 | { | 412 | { |
415 | if (fchdir(fd)) | 413 | if (fchdir(fd)) |
416 | bb_perror_msg_and_die("fchdir"); | 414 | bb_simple_perror_msg_and_die("fchdir"); |
417 | } | 415 | } |
418 | 416 | ||
419 | void FAST_FUNC xchroot(const char *path) | 417 | void FAST_FUNC xchroot(const char *path) |
@@ -463,7 +461,7 @@ int FAST_FUNC xsocket(int domain, int type, int protocol) | |||
463 | IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) | 461 | IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) |
464 | bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol); | 462 | bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol); |
465 | #else | 463 | #else |
466 | bb_perror_msg_and_die("socket"); | 464 | bb_simple_perror_msg_and_die("socket"); |
467 | #endif | 465 | #endif |
468 | } | 466 | } |
469 | 467 | ||
@@ -473,13 +471,13 @@ IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) | |||
473 | // Die with an error message if we can't bind a socket to an address. | 471 | // Die with an error message if we can't bind a socket to an address. |
474 | void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) | 472 | void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) |
475 | { | 473 | { |
476 | if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind"); | 474 | if (bind(sockfd, my_addr, addrlen)) bb_simple_perror_msg_and_die("bind"); |
477 | } | 475 | } |
478 | 476 | ||
479 | // Die with an error message if we can't listen for connections on a socket. | 477 | // Die with an error message if we can't listen for connections on a socket. |
480 | void FAST_FUNC xlisten(int s, int backlog) | 478 | void FAST_FUNC xlisten(int s, int backlog) |
481 | { | 479 | { |
482 | if (listen(s, backlog)) bb_perror_msg_and_die("listen"); | 480 | if (listen(s, backlog)) bb_simple_perror_msg_and_die("listen"); |
483 | } | 481 | } |
484 | 482 | ||
485 | /* Die with an error message if sendto failed. | 483 | /* Die with an error message if sendto failed. |
@@ -491,7 +489,7 @@ ssize_t FAST_FUNC xsendto(int s, const void *buf, size_t len, const struct socka | |||
491 | if (ret < 0) { | 489 | if (ret < 0) { |
492 | if (ENABLE_FEATURE_CLEAN_UP) | 490 | if (ENABLE_FEATURE_CLEAN_UP) |
493 | close(s); | 491 | close(s); |
494 | bb_perror_msg_and_die("sendto"); | 492 | bb_simple_perror_msg_and_die("sendto"); |
495 | } | 493 | } |
496 | return ret; | 494 | return ret; |
497 | } | 495 | } |
@@ -520,12 +518,12 @@ void FAST_FUNC selinux_or_die(void) | |||
520 | #if ENABLE_SELINUX | 518 | #if ENABLE_SELINUX |
521 | int rc = is_selinux_enabled(); | 519 | int rc = is_selinux_enabled(); |
522 | if (rc == 0) { | 520 | if (rc == 0) { |
523 | bb_error_msg_and_die("SELinux is disabled"); | 521 | bb_simple_error_msg_and_die("SELinux is disabled"); |
524 | } else if (rc < 0) { | 522 | } else if (rc < 0) { |
525 | bb_error_msg_and_die("is_selinux_enabled() failed"); | 523 | bb_simple_error_msg_and_die("is_selinux_enabled() failed"); |
526 | } | 524 | } |
527 | #else | 525 | #else |
528 | bb_error_msg_and_die("SELinux support is disabled"); | 526 | bb_simple_error_msg_and_die("SELinux support is disabled"); |
529 | #endif | 527 | #endif |
530 | } | 528 | } |
531 | 529 | ||
@@ -676,7 +674,7 @@ pid_t FAST_FUNC xfork(void) | |||
676 | pid_t pid; | 674 | pid_t pid; |
677 | pid = fork(); | 675 | pid = fork(); |
678 | if (pid < 0) /* wtf? */ | 676 | if (pid < 0) /* wtf? */ |
679 | bb_perror_msg_and_die("vfork"+1); | 677 | bb_simple_perror_msg_and_die("vfork"+1); |
680 | return pid; | 678 | return pid; |
681 | } | 679 | } |
682 | #endif | 680 | #endif |