From f61bf72e61f012e173acc15dfda71a3e5371bde1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 19 Jun 2020 20:55:26 -0700 Subject: Replace all strerror calls with wrapper. All string_utf8(strerror(x)) calls are replaced with errno_to_str(x). * sysif.c (errno_to_str): New function. (strerror_wrap): Now implemented via call to errno_to_str. (mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, rmdir_wrap, mknod_wrap, mkfifo_wrap, chmod_wrap, do_chown, symlink_wrap, link_wrap, readlink_wrap, close_wrap, exec_wrap, stat_impl, do_utimes, pipe_wrap, poll_wrap, getgroups_wrap, setuid_wrap, seteuid_wrap, setgid_wrap, setegid_wrap, setgroups_wrap, getresuid_wrap, getresgid_wrap, setresuid_wrap, setresgid_wrap, crypt_wrap, uname_wrap): Use errno_to_str. * sysif.h (errno_to_str): Declared. * ftw.c (ftw_wrap): Use errno_to_str. * socket.c (dgram_get_byte_callback, dgram_flush, sock_bind, open_sockfd, sock_connect, sock_listen, sock_accept, sock_shutdown, sock_timeout, socketpair_wrap): Likewise. * stream.c (errno_to_string): Likewise, and don't handle zero case any more; pass down to errno_to_str. (stdio_close, pipe_close open_directory, open_file, open_fileno, open_tail, fds_subst, open_command, open_subprocess, run, remove_path, rename_path): Use errno_to_str. * termios.c (tcgetattr_wrap, tcsetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_wrap): Likewise. diff --git a/termios.c b/termios.c --- termios.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'termios.c') diff --git a/termios.c b/termios.c index 5d7b26b0..ea73365c 100644 --- a/termios.c +++ b/termios.c @@ -44,6 +44,7 @@ #include "unwind.h" #include "stream.h" #include "struct.h" +#include "sysif.h" #include "termios.h" val termios_s, iflag_s, oflag_s, cflag_s, lflag_s, cc_s, ispeed_s, ospeed_s; @@ -256,7 +257,7 @@ static val tcgetattr_wrap(val stream) if (res < 0) uw_throwf(system_error_s, lit("tcgetattr failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return termios_unpack(&tio); } @@ -273,7 +274,7 @@ static val tcsetattr_wrap(val termios, val actions, val stream) if (res < 0) uw_throwf(system_error_s, lit("tcgetattr failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); termios_pack(&tio, termios); @@ -281,7 +282,7 @@ static val tcsetattr_wrap(val termios, val actions, val stream) if (res < 0) uw_throwf(system_error_s, lit("tcsetattr failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return termios; } @@ -294,7 +295,7 @@ static val tcsendbreak_wrap(val duration, val stream) if (res < 0) uw_throwf(system_error_s, lit("tcsendbreak failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return t; } @@ -306,7 +307,7 @@ static val tcdrain_wrap(val stream) if (res < 0) uw_throwf(system_error_s, lit("tcdrain failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return t; } @@ -318,7 +319,7 @@ static val tcflush_wrap(val queue, val stream) if (res < 0) uw_throwf(system_error_s, lit("tcflush failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return t; } @@ -330,7 +331,7 @@ static val tcflow_wrap(val action, val stream) if (res < 0) uw_throwf(system_error_s, lit("tcflow failed: ~d/~s"), - num(errno), string_utf8(strerror(errno)), nao); + num(errno), errno_to_str(errno), nao); return t; } -- cgit v1.2.3