[hackers] [st] remove confusing SERRNO macro || Markus Teich
commit 3269bf213d8fdbfb78e9eb1cc9eb677114508e57
Author: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Sun Apr 20 13:15:40 2014 +0200
remove confusing SERRNO macro
I found the SERRNO Macro slightly confusing, since you have to look
it up, if you don't know it already. A web search showed it does
not seem to be any kind of standard. Also there was no reason in
the commit log when it was introduced in 2009. As you can see it
also leads to new patches, which don't use this macro (probably the
author did not know about it).
diff --git a/st.c b/st.c
index e510565..e017940 100644
--- a/st.c
+++ b/st.c
_AT_@ -65,7 +65,6 @@ char *argv0;
#define REDRAW_TIMEOUT (80*1000) /* 80 ms */
/* macros */
-#define SERRNO strerror(errno)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a[0]))
_AT_@ -1181,7 +1180,7 @@ sigchld(int a) {
int stat = 0;
if(waitpid(pid, &stat, 0) < 0)
- die("Waiting for pid %hd failed: %s
", pid, SERRNO);
+ die("Waiting for pid %hd failed: %s
", pid, strerror(errno));
if(WIFEXITED(stat)) {
exit(WEXITSTATUS(stat));
_AT_@ -1197,7 +1196,7 @@ ttynew(void) {
/* seems to work fine on linux, openbsd and freebsd */
if(openpty(&m, &s, NULL, NULL, &w) < 0)
- die("openpty failed: %s
", SERRNO);
+ die("openpty failed: %s
", strerror(errno));
switch(pid = fork()) {
case -1:
_AT_@ -1209,7 +1208,7 @@ ttynew(void) {
dup2(s, STDOUT_FILENO);
dup2(s, STDERR_FILENO);
if(ioctl(s, TIOCSCTTY, NULL) < 0)
- die("ioctl TIOCSCTTY failed: %s
", SERRNO);
+ die("ioctl TIOCSCTTY failed: %s
", strerror(errno));
close(s);
close(m);
execsh();
_AT_@ -1252,7 +1251,7 @@ ttyread(void) {
/* append read bytes to unprocessed bytes */
if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
- die("Couldn't read from shell: %s
", SERRNO);
+ die("Couldn't read from shell: %s
", strerror(errno));
/* process every complete utf8 char */
buflen += ret;
_AT_@ -1271,7 +1270,7 @@ ttyread(void) {
void
ttywrite(const char *s, size_t n) {
if(write(cmdfd, s, n) == -1)
- die("write error on tty: %s
", SERRNO);
+ die("write error on tty: %s
", strerror(errno));
}
void
_AT_@ -1290,7 +1289,7 @@ ttyresize(void) {
w.ws_xpixel = xw.tw;
w.ws_ypixel = xw.th;
if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
- fprintf(stderr, "Couldn't set window size: %s
", SERRNO);
+ fprintf(stderr, "Couldn't set window size: %s
", strerror(errno));
}
int
_AT_@ -3750,7 +3749,7 @@ run(void) {
if(select(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv) < 0) {
if(errno == EINTR)
continue;
- die("select failed: %s
", SERRNO);
+ die("select failed: %s
", strerror(errno));
}
if(FD_ISSET(cmdfd, &rfd)) {
ttyread();
Received on Tue Apr 22 2014 - 07:35:33 CEST
This archive was generated by hypermail 2.3.0
: Tue Apr 22 2014 - 07:36:07 CEST