summaryrefslogtreecommitdiff
path: root/libbb/xfuncs_printf.c
diff options
context:
space:
mode:
authorDenys Vlasenko2022-01-13 12:56:10 +0100
committerDenys Vlasenko2022-01-13 12:56:10 +0100
commitc2788f88f430da8ae5fb5f293b13fc2b167ea2fe (patch)
tree44e3fd94292a3ef13ecdbf14d469459e00be1150 /libbb/xfuncs_printf.c
parent931c55f9e2b41473132683488820c6fb7c47506b (diff)
downloadbusybox-c2788f88f430da8ae5fb5f293b13fc2b167ea2fe.zip
busybox-c2788f88f430da8ae5fb5f293b13fc2b167ea2fe.tar.gz
libbb: introduce and use chdir_or_warn()
function old new delta chdir_or_warn - 37 +37 send_cgi_and_exit 720 711 -9 xchdir 27 15 -12 setup_environment 233 217 -16 fork_job 449 433 -16 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 37/-53) Total: -16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/xfuncs_printf.c')
-rw-r--r--libbb/xfuncs_printf.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index fc630d1..842d10c 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -415,11 +415,18 @@ void FAST_FUNC xseteuid(uid_t euid)
if (seteuid(euid)) bb_simple_perror_msg_and_die("seteuid");
}
+int FAST_FUNC chdir_or_warn(const char *path)
+{
+ int r = chdir(path);
+ if (r != 0)
+ bb_perror_msg("can't change directory to '%s'", path);
+ return r;
+}
// Die if we can't chdir to a new path.
void FAST_FUNC xchdir(const char *path)
{
- if (chdir(path))
- bb_perror_msg_and_die("can't change directory to '%s'", path);
+ if (chdir_or_warn(path) != 0)
+ xfunc_die();
}
void FAST_FUNC xfchdir(int fd)