aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorJames Byrne <james.byrne@origamienergy.com>2019-07-02 11:35:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-07-02 11:35:03 +0200
commit6937487be73cd4563b876413277a295a5fe2f32c (patch)
treef16cc9999a7c827891e6ec8d99c699fc791008ee /libbb
parentcaecfdc20d450686cd1f7e9b5f650322f894b3c2 (diff)
downloadbusybox-w32-6937487be73cd4563b876413277a295a5fe2f32c.tar.gz
busybox-w32-6937487be73cd4563b876413277a295a5fe2f32c.tar.bz2
busybox-w32-6937487be73cd4563b876413277a295a5fe2f32c.zip
libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c10
-rw-r--r--libbb/bb_getgroups.c2
-rw-r--r--libbb/bbunit.c2
-rw-r--r--libbb/capability.c2
-rw-r--r--libbb/change_identity.c2
-rw-r--r--libbb/copy_file.c2
-rw-r--r--libbb/copyfd.c6
-rw-r--r--libbb/die_if_bad_username.c2
-rw-r--r--libbb/dump.c4
-rw-r--r--libbb/fflush_stdout_and_exit.c2
-rw-r--r--libbb/get_console.c2
-rw-r--r--libbb/get_volsize.c4
-rw-r--r--libbb/getpty.c6
-rw-r--r--libbb/herror_msg.c10
-rw-r--r--libbb/mtab.c4
-rw-r--r--libbb/perror_nomsg.c4
-rw-r--r--libbb/perror_nomsg_and_die.c4
-rw-r--r--libbb/read_printf.c2
-rw-r--r--libbb/safe_poll.c2
-rw-r--r--libbb/selinux_common.c2
-rw-r--r--libbb/time.c2
-rw-r--r--libbb/update_passwd.c4
-rw-r--r--libbb/uuencode.c2
-rw-r--r--libbb/verror_msg.c15
-rw-r--r--libbb/warn_ignoring_args.c2
-rw-r--r--libbb/xconnect.c4
-rw-r--r--libbb/xfuncs.c2
-rw-r--r--libbb/xfuncs_printf.c44
-rw-r--r--libbb/xgetcwd.c2
-rw-r--r--libbb/xgethostbyname.c2
30 files changed, 88 insertions, 65 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index fa19e8488..9fa17cfa1 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -631,7 +631,7 @@ static void check_suid(int applet_no)
631 /* same group / in group */ 631 /* same group / in group */
632 m >>= 3; 632 m >>= 3;
633 if (!(m & S_IXOTH)) /* is x bit not set? */ 633 if (!(m & S_IXOTH)) /* is x bit not set? */
634 bb_error_msg_and_die("you have no permission to run this applet"); 634 bb_simple_error_msg_and_die("you have no permission to run this applet");
635 635
636 /* We set effective AND saved ids. If saved-id is not set 636 /* We set effective AND saved ids. If saved-id is not set
637 * like we do below, seteuid(0) can still later succeed! */ 637 * like we do below, seteuid(0) can still later succeed! */
@@ -643,7 +643,7 @@ static void check_suid(int applet_no)
643 rgid = sct->m_ugid.gid; 643 rgid = sct->m_ugid.gid;
644 /* else: we will set egid = rgid, thus dropping sgid effect */ 644 /* else: we will set egid = rgid, thus dropping sgid effect */
645 if (setresgid(-1, rgid, rgid)) 645 if (setresgid(-1, rgid, rgid))
646 bb_perror_msg_and_die("setresgid"); 646 bb_simple_perror_msg_and_die("setresgid");
647 647
648 /* Are we directed to change uid 648 /* Are we directed to change uid
649 * (APPLET = s** USER.GROUP or APPLET = S** USER.GROUP)? 649 * (APPLET = s** USER.GROUP or APPLET = S** USER.GROUP)?
@@ -653,7 +653,7 @@ static void check_suid(int applet_no)
653 uid = sct->m_ugid.uid; 653 uid = sct->m_ugid.uid;
654 /* else: we will set euid = ruid, thus dropping suid effect */ 654 /* else: we will set euid = ruid, thus dropping suid effect */
655 if (setresuid(-1, uid, uid)) 655 if (setresuid(-1, uid, uid))
656 bb_perror_msg_and_die("setresuid"); 656 bb_simple_perror_msg_and_die("setresuid");
657 657
658 goto ret; 658 goto ret;
659 } 659 }
@@ -663,7 +663,7 @@ static void check_suid(int applet_no)
663 663
664 if (!onetime) { 664 if (!onetime) {
665 onetime = 1; 665 onetime = 1;
666 bb_error_msg("using fallback suid method"); 666 bb_simple_error_msg("using fallback suid method");
667 } 667 }
668 } 668 }
669# endif 669# endif
@@ -673,7 +673,7 @@ static void check_suid(int applet_no)
673 /* Real uid is not 0. If euid isn't 0 too, suid bit 673 /* Real uid is not 0. If euid isn't 0 too, suid bit
674 * is most probably not set on our executable */ 674 * is most probably not set on our executable */
675 if (geteuid()) 675 if (geteuid())
676 bb_error_msg_and_die("must be suid to work properly"); 676 bb_simple_error_msg_and_die("must be suid to work properly");
677 } else if (APPLET_SUID(applet_no) == BB_SUID_DROP) { 677 } else if (APPLET_SUID(applet_no) == BB_SUID_DROP) {
678 /* 678 /*
679 * Drop all privileges. 679 * Drop all privileges.
diff --git a/libbb/bb_getgroups.c b/libbb/bb_getgroups.c
index 59ae53738..5d83c729a 100644
--- a/libbb/bb_getgroups.c
+++ b/libbb/bb_getgroups.c
@@ -38,7 +38,7 @@ gid_t* FAST_FUNC bb_getgroups(int *ngroups, gid_t *group_array)
38 continue; 38 continue;
39 } 39 }
40 /* Some other error (should never happen on Linux) */ 40 /* Some other error (should never happen on Linux) */
41 bb_perror_msg_and_die("getgroups"); 41 bb_simple_perror_msg_and_die("getgroups");
42 } 42 }
43 43
44 if (ngroups) 44 if (ngroups)
diff --git a/libbb/bbunit.c b/libbb/bbunit.c
index 5f8d980a3..ccd909d78 100644
--- a/libbb/bbunit.c
+++ b/libbb/bbunit.c
@@ -60,6 +60,6 @@ int unit_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
60 return EXIT_FAILURE; 60 return EXIT_FAILURE;
61 } 61 }
62 62
63 bb_error_msg("All tests passed"); 63 bb_simple_error_msg("All tests passed");
64 return EXIT_SUCCESS; 64 return EXIT_SUCCESS;
65} 65}
diff --git a/libbb/capability.c b/libbb/capability.c
index d0ae78b91..23afd8eb9 100644
--- a/libbb/capability.c
+++ b/libbb/capability.c
@@ -119,7 +119,7 @@ void FAST_FUNC getcaps(void *arg)
119 caps->u32s = _LINUX_CAPABILITY_U32S_3; 119 caps->u32s = _LINUX_CAPABILITY_U32S_3;
120 break; 120 break;
121 default: 121 default:
122 bb_error_msg_and_die("unsupported capability version"); 122 bb_simple_error_msg_and_die("unsupported capability version");
123 } 123 }
124 124
125 if (capget(&caps->header, caps->data) != 0) 125 if (capget(&caps->header, caps->data) != 0)
diff --git a/libbb/change_identity.c b/libbb/change_identity.c
index 20d7c5f2d..9ff741234 100644
--- a/libbb/change_identity.c
+++ b/libbb/change_identity.c
@@ -51,7 +51,7 @@ void FAST_FUNC change_identity(const struct passwd *pw)
51 return; 51 return;
52 } 52 }
53 53
54 bb_perror_msg_and_die("can't set groups"); 54 bb_simple_perror_msg_and_die("can't set groups");
55 } 55 }
56 56
57 xsetgid(pw->pw_gid); 57 xsetgid(pw->pw_gid);
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 2d6557cd4..49d1ec9c6 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -327,7 +327,7 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
327 ) { 327 ) {
328 security_context_t con; 328 security_context_t con;
329 if (getfscreatecon(&con) == -1) { 329 if (getfscreatecon(&con) == -1) {
330 bb_perror_msg("getfscreatecon"); 330 bb_simple_perror_msg("getfscreatecon");
331 return -1; 331 return -1;
332 } 332 }
333 if (con) { 333 if (con) {
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index dd0517cd6..ae5c26999 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -87,7 +87,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
87 rd = safe_read(src_fd, buffer, 87 rd = safe_read(src_fd, buffer,
88 size > buffer_size ? buffer_size : size); 88 size > buffer_size ? buffer_size : size);
89 if (rd < 0) { 89 if (rd < 0) {
90 bb_perror_msg(bb_msg_read_error); 90 bb_simple_perror_msg(bb_msg_read_error);
91 break; 91 break;
92 } 92 }
93 read_ok: 93 read_ok:
@@ -100,7 +100,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
100 ssize_t wr = full_write(dst_fd, buffer, rd); 100 ssize_t wr = full_write(dst_fd, buffer, rd);
101 if (wr < rd) { 101 if (wr < rd) {
102 if (!continue_on_write_error) { 102 if (!continue_on_write_error) {
103 bb_perror_msg(bb_msg_write_error); 103 bb_simple_perror_msg(bb_msg_write_error);
104 break; 104 break;
105 } 105 }
106 dst_fd = -1; 106 dst_fd = -1;
@@ -151,7 +151,7 @@ void FAST_FUNC bb_copyfd_exact_size(int fd1, int fd2, off_t size)
151 if (sz == (size >= 0 ? size : -size)) 151 if (sz == (size >= 0 ? size : -size))
152 return; 152 return;
153 if (sz != -1) 153 if (sz != -1)
154 bb_error_msg_and_die("short read"); 154 bb_simple_error_msg_and_die("short read");
155 /* if sz == -1, bb_copyfd_XX already complained */ 155 /* if sz == -1, bb_copyfd_XX already complained */
156 xfunc_die(); 156 xfunc_die();
157} 157}
diff --git a/libbb/die_if_bad_username.c b/libbb/die_if_bad_username.c
index 46f103340..e5e1160c4 100644
--- a/libbb/die_if_bad_username.c
+++ b/libbb/die_if_bad_username.c
@@ -57,5 +57,5 @@ void FAST_FUNC die_if_bad_username(const char *name)
57 * including the terminating null byte. 57 * including the terminating null byte.
58 */ 58 */
59 if (name - start >= LOGIN_NAME_MAX) 59 if (name - start >= LOGIN_NAME_MAX)
60 bb_error_msg_and_die("name is too long"); 60 bb_simple_error_msg_and_die("name is too long");
61} 61}
diff --git a/libbb/dump.c b/libbb/dump.c
index b4b49d709..8029cca0e 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -199,7 +199,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
199 pr->bcnt = fu->bcnt; 199 pr->bcnt = fu->bcnt;
200 if (fu->bcnt == 0) { 200 if (fu->bcnt == 0) {
201 if (!prec) 201 if (!prec)
202 bb_error_msg_and_die("%%s needs precision or byte count"); 202 bb_simple_error_msg_and_die("%%s needs precision or byte count");
203 pr->bcnt = atoi(prec); 203 pr->bcnt = atoi(prec);
204 } 204 }
205 } else 205 } else
@@ -266,7 +266,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
266 266
267 /* only one conversion character if byte count */ 267 /* only one conversion character if byte count */
268 if (!(pr->flags & F_ADDRESS) && fu->bcnt && nconv++) { 268 if (!(pr->flags & F_ADDRESS) && fu->bcnt && nconv++) {
269 bb_error_msg_and_die("byte count with multiple conversion characters"); 269 bb_simple_error_msg_and_die("byte count with multiple conversion characters");
270 } 270 }
271 } 271 }
272 /* 272 /*
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c
index 4c689c0fb..5df74170e 100644
--- a/libbb/fflush_stdout_and_exit.c
+++ b/libbb/fflush_stdout_and_exit.c
@@ -15,7 +15,7 @@ void FAST_FUNC fflush_stdout_and_exit(int retval)
15{ 15{
16 xfunc_error_retval = retval; 16 xfunc_error_retval = retval;
17 if (fflush(stdout)) 17 if (fflush(stdout))
18 bb_perror_msg_and_die(bb_msg_standard_output); 18 bb_simple_perror_msg_and_die(bb_msg_standard_output);
19 /* In case we are in NOFORK applet. Do not exit() directly, 19 /* In case we are in NOFORK applet. Do not exit() directly,
20 * but use xfunc_die() */ 20 * but use xfunc_die() */
21 xfunc_die(); 21 xfunc_die();
diff --git a/libbb/get_console.c b/libbb/get_console.c
index 0b53524aa..7f2c75332 100644
--- a/libbb/get_console.c
+++ b/libbb/get_console.c
@@ -62,7 +62,7 @@ int FAST_FUNC get_console_fd_or_die(void)
62 } 62 }
63 } 63 }
64 64
65 bb_error_msg_and_die("can't open console"); 65 bb_simple_error_msg_and_die("can't open console");
66} 66}
67 67
68/* From <linux/vt.h> */ 68/* From <linux/vt.h> */
diff --git a/libbb/get_volsize.c b/libbb/get_volsize.c
index 241ceda9b..087efb3c7 100644
--- a/libbb/get_volsize.c
+++ b/libbb/get_volsize.c
@@ -18,7 +18,7 @@ uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
18 if (override) { 18 if (override) {
19 result = XATOOFF(override); 19 result = XATOOFF(override);
20 if (result >= (uoff_t)(MAXINT(off_t)) / override_units) 20 if (result >= (uoff_t)(MAXINT(off_t)) / override_units)
21 bb_error_msg_and_die("image size is too big"); 21 bb_simple_error_msg_and_die("image size is too big");
22 result *= override_units; 22 result *= override_units;
23 /* seek past end fails on block devices but works on files */ 23 /* seek past end fails on block devices but works on files */
24 if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) { 24 if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) {
@@ -42,7 +42,7 @@ uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
42 * 42 *
43 * Picked 16k arbitrarily: */ 43 * Picked 16k arbitrarily: */
44 if (result < 16*1024) 44 if (result < 16*1024)
45 bb_error_msg_and_die("image is too small"); 45 bb_simple_error_msg_and_die("image is too small");
46 46
47 return result; 47 return result;
48} 48}
diff --git a/libbb/getpty.c b/libbb/getpty.c
index 5d24ca930..9ec6265ad 100644
--- a/libbb/getpty.c
+++ b/libbb/getpty.c
@@ -23,14 +23,14 @@ int FAST_FUNC xgetpty(char *line)
23 const char *name; 23 const char *name;
24 name = ptsname(p); /* find out the name of slave pty */ 24 name = ptsname(p); /* find out the name of slave pty */
25 if (!name) { 25 if (!name) {
26 bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); 26 bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
27 } 27 }
28 safe_strncpy(line, name, GETPTY_BUFSIZE); 28 safe_strncpy(line, name, GETPTY_BUFSIZE);
29 } 29 }
30# else 30# else
31 /* find out the name of slave pty */ 31 /* find out the name of slave pty */
32 if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) { 32 if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) {
33 bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)"); 33 bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
34 } 34 }
35 line[GETPTY_BUFSIZE-1] = '\0'; 35 line[GETPTY_BUFSIZE-1] = '\0';
36# endif 36# endif
@@ -61,5 +61,5 @@ int FAST_FUNC xgetpty(char *line)
61 } 61 }
62 } 62 }
63#endif /* FEATURE_DEVPTS */ 63#endif /* FEATURE_DEVPTS */
64 bb_error_msg_and_die("can't find free pty"); 64 bb_simple_error_msg_and_die("can't find free pty");
65} 65}
diff --git a/libbb/herror_msg.c b/libbb/herror_msg.c
index d041076e0..a7dd98679 100644
--- a/libbb/herror_msg.c
+++ b/libbb/herror_msg.c
@@ -26,3 +26,13 @@ void FAST_FUNC bb_herror_msg_and_die(const char *s, ...)
26 va_end(p); 26 va_end(p);
27 xfunc_die(); 27 xfunc_die();
28} 28}
29
30void FAST_FUNC bb_simple_herror_msg(const char *s)
31{
32 bb_herror_msg("%s", s);
33}
34
35void FAST_FUNC bb_simple_herror_msg_and_die(const char *s)
36{
37 bb_herror_msg_and_die("%s", s);
38}
diff --git a/libbb/mtab.c b/libbb/mtab.c
index 131705ddb..aa1a2a103 100644
--- a/libbb/mtab.c
+++ b/libbb/mtab.c
@@ -21,7 +21,7 @@ void FAST_FUNC erase_mtab(const char *name)
21 /* Bummer. Fall back on trying the /proc filesystem */ 21 /* Bummer. Fall back on trying the /proc filesystem */
22 if (!mountTable) mountTable = setmntent("/proc/mounts", "r"); 22 if (!mountTable) mountTable = setmntent("/proc/mounts", "r");
23 if (!mountTable) { 23 if (!mountTable) {
24 bb_perror_msg(bb_path_mtab_file); 24 bb_simple_perror_msg(bb_path_mtab_file);
25 return; 25 return;
26 } 26 }
27 27
@@ -49,6 +49,6 @@ void FAST_FUNC erase_mtab(const char *name)
49 } 49 }
50 endmntent(mountTable); 50 endmntent(mountTable);
51 } else if (errno != EROFS) 51 } else if (errno != EROFS)
52 bb_perror_msg(bb_path_mtab_file); 52 bb_simple_perror_msg(bb_path_mtab_file);
53} 53}
54#endif 54#endif
diff --git a/libbb/perror_nomsg.c b/libbb/perror_nomsg.c
index a2a11cc8e..d7d53de44 100644
--- a/libbb/perror_nomsg.c
+++ b/libbb/perror_nomsg.c
@@ -12,11 +12,11 @@
12 * instead of including libbb.h */ 12 * instead of including libbb.h */
13//#include "libbb.h" 13//#include "libbb.h"
14#include "platform.h" 14#include "platform.h"
15extern void bb_perror_msg(const char *s, ...) FAST_FUNC; 15extern void bb_simple_perror_msg(const char *s) FAST_FUNC;
16 16
17/* suppress gcc "no previous prototype" warning */ 17/* suppress gcc "no previous prototype" warning */
18void FAST_FUNC bb_perror_nomsg(void); 18void FAST_FUNC bb_perror_nomsg(void);
19void FAST_FUNC bb_perror_nomsg(void) 19void FAST_FUNC bb_perror_nomsg(void)
20{ 20{
21 bb_perror_msg(0); 21 bb_simple_perror_msg(0);
22} 22}
diff --git a/libbb/perror_nomsg_and_die.c b/libbb/perror_nomsg_and_die.c
index 543ff5178..bea5f25a5 100644
--- a/libbb/perror_nomsg_and_die.c
+++ b/libbb/perror_nomsg_and_die.c
@@ -12,11 +12,11 @@
12 * instead of including libbb.h */ 12 * instead of including libbb.h */
13//#include "libbb.h" 13//#include "libbb.h"
14#include "platform.h" 14#include "platform.h"
15extern void bb_perror_msg_and_die(const char *s, ...) FAST_FUNC; 15extern void bb_simple_perror_msg_and_die(const char *s) FAST_FUNC;
16 16
17/* suppress gcc "no previous prototype" warning */ 17/* suppress gcc "no previous prototype" warning */
18void FAST_FUNC bb_perror_nomsg_and_die(void); 18void FAST_FUNC bb_perror_nomsg_and_die(void);
19void FAST_FUNC bb_perror_nomsg_and_die(void) 19void FAST_FUNC bb_perror_nomsg_and_die(void)
20{ 20{
21 bb_perror_msg_and_die(0); 21 bb_simple_perror_msg_and_die(0);
22} 22}
diff --git a/libbb/read_printf.c b/libbb/read_printf.c
index cb582c080..0cd04ab7b 100644
--- a/libbb/read_printf.c
+++ b/libbb/read_printf.c
@@ -217,7 +217,7 @@ void FAST_FUNC xread(int fd, void *buf, size_t count)
217 if (count) { 217 if (count) {
218 ssize_t size = full_read(fd, buf, count); 218 ssize_t size = full_read(fd, buf, count);
219 if ((size_t)size != count) 219 if ((size_t)size != count)
220 bb_error_msg_and_die("short read"); 220 bb_simple_error_msg_and_die("short read");
221 } 221 }
222} 222}
223 223
diff --git a/libbb/safe_poll.c b/libbb/safe_poll.c
index cf93a9774..a07e785f3 100644
--- a/libbb/safe_poll.c
+++ b/libbb/safe_poll.c
@@ -27,7 +27,7 @@ int FAST_FUNC safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout)
27 /* I doubt many callers would handle this correctly! */ 27 /* I doubt many callers would handle this correctly! */
28 if (errno == ENOMEM) 28 if (errno == ENOMEM)
29 continue; 29 continue;
30 bb_perror_msg("poll"); 30 bb_simple_perror_msg("poll");
31 return n; 31 return n;
32 } 32 }
33} 33}
diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c
index c2585557f..f917a1c6a 100644
--- a/libbb/selinux_common.c
+++ b/libbb/selinux_common.c
@@ -48,7 +48,7 @@ void FAST_FUNC selinux_preserve_fcontext(int fdesc)
48 if (fgetfilecon(fdesc, &context) < 0) { 48 if (fgetfilecon(fdesc, &context) < 0) {
49 if (errno == ENODATA || errno == ENOTSUP) 49 if (errno == ENODATA || errno == ENOTSUP)
50 return; 50 return;
51 bb_perror_msg_and_die("fgetfilecon failed"); 51 bb_simple_perror_msg_and_die("fgetfilecon failed");
52 } 52 }
53 setfscreatecon_or_die(context); 53 setfscreatecon_or_die(context);
54 freecon(context); 54 freecon(context);
diff --git a/libbb/time.c b/libbb/time.c
index f9b8da0b3..cab0ad602 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -258,7 +258,7 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
258static void get_mono(struct timespec *ts) 258static void get_mono(struct timespec *ts)
259{ 259{
260 if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts)) 260 if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
261 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed"); 261 bb_simple_error_msg_and_die("clock_gettime(MONOTONIC) failed");
262} 262}
263unsigned long long FAST_FUNC monotonic_ns(void) 263unsigned long long FAST_FUNC monotonic_ns(void)
264{ 264{
diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c
index dc967683a..c605c4c64 100644
--- a/libbb/update_passwd.c
+++ b/libbb/update_passwd.c
@@ -25,7 +25,7 @@ static void check_selinux_update_passwd(const char *username)
25 return; /* No need to check */ 25 return; /* No need to check */
26 26
27 if (getprevcon_raw(&context) < 0) 27 if (getprevcon_raw(&context) < 0)
28 bb_perror_msg_and_die("getprevcon failed"); 28 bb_simple_perror_msg_and_die("getprevcon failed");
29 seuser = strtok(context, ":"); 29 seuser = strtok(context, ":");
30 if (!seuser) 30 if (!seuser)
31 bb_error_msg_and_die("invalid context '%s'", context); 31 bb_error_msg_and_die("invalid context '%s'", context);
@@ -42,7 +42,7 @@ static void check_selinux_update_passwd(const char *username)
42 42
43 if (selinux_check_passwd_access(av) != 0) 43 if (selinux_check_passwd_access(av) != 0)
44 die: 44 die:
45 bb_error_msg_and_die("SELinux: access denied"); 45 bb_simple_error_msg_and_die("SELinux: access denied");
46 } 46 }
47 if (ENABLE_FEATURE_CLEAN_UP) 47 if (ENABLE_FEATURE_CLEAN_UP)
48 freecon(context); 48 freecon(context);
diff --git a/libbb/uuencode.c b/libbb/uuencode.c
index f32a3da7d..d36b34f63 100644
--- a/libbb/uuencode.c
+++ b/libbb/uuencode.c
@@ -213,7 +213,7 @@ void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags)
213 if (*in_tail == '\0') 213 if (*in_tail == '\0')
214 return; 214 return;
215 /* No */ 215 /* No */
216 bb_error_msg_and_die("truncated base64 input"); 216 bb_simple_error_msg_and_die("truncated base64 input");
217 } 217 }
218 218
219 /* It was partial decode */ 219 /* It was partial decode */
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c
index 6d3459905..71512aee2 100644
--- a/libbb/verror_msg.c
+++ b/libbb/verror_msg.c
@@ -197,4 +197,19 @@ void FAST_FUNC bb_info_msg(const char *s, ...)
197 bb_vinfo_msg(s, p); 197 bb_vinfo_msg(s, p);
198 va_end(p); 198 va_end(p);
199} 199}
200
201void FAST_FUNC bb_simple_info_msg(const char *s)
202{
203 bb_info_msg("%s", s);
204}
200#endif 205#endif
206
207void FAST_FUNC bb_simple_error_msg(const char *s)
208{
209 bb_error_msg("%s", s);
210}
211
212void FAST_FUNC bb_simple_error_msg_and_die(const char *s)
213{
214 bb_error_msg_and_die("%s", s);
215}
diff --git a/libbb/warn_ignoring_args.c b/libbb/warn_ignoring_args.c
index 3f3025c03..b24546e41 100644
--- a/libbb/warn_ignoring_args.c
+++ b/libbb/warn_ignoring_args.c
@@ -12,7 +12,7 @@
12void FAST_FUNC bb_warn_ignoring_args(char *arg) 12void FAST_FUNC bb_warn_ignoring_args(char *arg)
13{ 13{
14 if (arg) { 14 if (arg) {
15 bb_error_msg("ignoring all arguments"); 15 bb_simple_error_msg("ignoring all arguments");
16 } 16 }
17} 17}
18#endif 18#endif
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index eb2871cb1..e9a2470e4 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -66,7 +66,7 @@ int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
66int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM, 66int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM,
67 const char *iface UNUSED_PARAM) 67 const char *iface UNUSED_PARAM)
68{ 68{
69 bb_error_msg("SO_BINDTODEVICE is not supported on this system"); 69 bb_simple_error_msg("SO_BINDTODEVICE is not supported on this system");
70 return -1; 70 return -1;
71} 71}
72#endif 72#endif
@@ -109,7 +109,7 @@ void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen)
109 bb_perror_msg_and_die("%s (%s)", 109 bb_perror_msg_and_die("%s (%s)",
110 "can't connect to remote host", 110 "can't connect to remote host",
111 inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr)); 111 inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr));
112 bb_perror_msg_and_die("can't connect to remote host"); 112 bb_simple_perror_msg_and_die("can't connect to remote host");
113 } 113 }
114} 114}
115 115
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index b4d512bd6..ee2dbdef1 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -426,6 +426,6 @@ int FAST_FUNC wait_for_exitstatus(pid_t pid)
426 426
427 n = safe_waitpid(pid, &exit_status, 0); 427 n = safe_waitpid(pid, &exit_status, 0);
428 if (n < 0) 428 if (n < 0)
429 bb_perror_msg_and_die("waitpid"); 429 bb_simple_perror_msg_and_die("waitpid");
430 return exit_status; 430 return exit_status;
431} 431}
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 6cc60f6c0..93f325c62 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -27,7 +27,7 @@
27 27
28void FAST_FUNC bb_die_memory_exhausted(void) 28void 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)
215void FAST_FUNC xpipe(int filedes[2]) 215void 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
221void FAST_FUNC xdup2(int from, int to) 221void 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)
259void FAST_FUNC xclose(int fd) 259void 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.)
385void FAST_FUNC xsetgid(gid_t gid) 383void 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.)
391void FAST_FUNC xsetuid(uid_t uid) 389void 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
396void FAST_FUNC xsetegid(gid_t egid) 394void 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
401void FAST_FUNC xseteuid(uid_t euid) 399void 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)
413void FAST_FUNC xfchdir(int fd) 411void 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
419void FAST_FUNC xchroot(const char *path) 417void FAST_FUNC xchroot(const char *path)
@@ -463,7 +461,7 @@ int FAST_FUNC xsocket(int domain, int type, int protocol)
463IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) 461IF_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.
474void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) 472void 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.
480void FAST_FUNC xlisten(int s, int backlog) 478void 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}
@@ -519,12 +517,12 @@ void FAST_FUNC selinux_or_die(void)
519#if ENABLE_SELINUX 517#if ENABLE_SELINUX
520 int rc = is_selinux_enabled(); 518 int rc = is_selinux_enabled();
521 if (rc == 0) { 519 if (rc == 0) {
522 bb_error_msg_and_die("SELinux is disabled"); 520 bb_simple_error_msg_and_die("SELinux is disabled");
523 } else if (rc < 0) { 521 } else if (rc < 0) {
524 bb_error_msg_and_die("is_selinux_enabled() failed"); 522 bb_simple_error_msg_and_die("is_selinux_enabled() failed");
525 } 523 }
526#else 524#else
527 bb_error_msg_and_die("SELinux support is disabled"); 525 bb_simple_error_msg_and_die("SELinux support is disabled");
528#endif 526#endif
529} 527}
530 528
@@ -675,7 +673,7 @@ pid_t FAST_FUNC xfork(void)
675 pid_t pid; 673 pid_t pid;
676 pid = fork(); 674 pid = fork();
677 if (pid < 0) /* wtf? */ 675 if (pid < 0) /* wtf? */
678 bb_perror_msg_and_die("vfork"+1); 676 bb_simple_perror_msg_and_die("vfork"+1);
679 return pid; 677 return pid;
680} 678}
681#endif 679#endif
diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c
index 7f9088bda..f4e768982 100644
--- a/libbb/xgetcwd.c
+++ b/libbb/xgetcwd.c
@@ -33,7 +33,7 @@ xrealloc_getcwd_or_warn(char *cwd)
33 if (errno == ERANGE) 33 if (errno == ERANGE)
34 continue; 34 continue;
35 free(cwd); 35 free(cwd);
36 bb_perror_msg("getcwd"); 36 bb_simple_perror_msg("getcwd");
37 return NULL; 37 return NULL;
38 } 38 }
39 cwd = xrealloc(cwd, strlen(cwd) + 1); 39 cwd = xrealloc(cwd, strlen(cwd) + 1);
diff --git a/libbb/xgethostbyname.c b/libbb/xgethostbyname.c
index 89d0329cc..9446daba7 100644
--- a/libbb/xgethostbyname.c
+++ b/libbb/xgethostbyname.c
@@ -12,6 +12,6 @@ struct hostent* FAST_FUNC xgethostbyname(const char *name)
12{ 12{
13 struct hostent *retval = gethostbyname(name); 13 struct hostent *retval = gethostbyname(name);
14 if (!retval) 14 if (!retval)
15 bb_herror_msg_and_die("%s", name); 15 bb_simple_herror_msg_and_die(name);
16 return retval; 16 return retval;
17} 17}