summaryrefslogtreecommitdiffstats
path: root/termios.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-06-19 20:55:26 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-06-20 12:25:51 -0700
commitf61bf72e61f012e173acc15dfda71a3e5371bde1 (patch)
treef1830c5a993d594e200423243c5dffcbcd88aad7 /termios.c
parent29a25713116323adcac696a090420ed3c1e73e5f (diff)
downloadtxr-f61bf72e61f012e173acc15dfda71a3e5371bde1.tar.gz
txr-f61bf72e61f012e173acc15dfda71a3e5371bde1.tar.bz2
txr-f61bf72e61f012e173acc15dfda71a3e5371bde1.zip
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
Diffstat (limited to 'termios.c')
-rw-r--r--termios.c15
1 files changed, 8 insertions, 7 deletions
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;
}