commit: 3269bf213d8fdbfb78e9eb1cc9eb677114508e57
parent: 4ad2fc7f18c8a58d9f88d9a91fb4972849cfd964
Author: Markus Teich <markus.teich@stusta.mhn.de>
Date: Sun, 20 Apr 2014 13:15:40 +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).
Diffstat:
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/st.c b/st.c
@@ -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]))
@@ -1181,7 +1180,7 @@ sigchld(int a) {
int stat = 0;
if(waitpid(pid, &stat, 0) < 0)
- die("Waiting for pid %hd failed: %s\n", pid, SERRNO);
+ die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
if(WIFEXITED(stat)) {
exit(WEXITSTATUS(stat));
@@ -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\n", SERRNO);
+ die("openpty failed: %s\n", strerror(errno));
switch(pid = fork()) {
case -1:
@@ -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\n", SERRNO);
+ die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s);
close(m);
execsh();
@@ -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\n", SERRNO);
+ die("Couldn't read from shell: %s\n", strerror(errno));
/* process every complete utf8 char */
buflen += ret;
@@ -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\n", SERRNO);
+ die("write error on tty: %s\n", strerror(errno));
}
void
@@ -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\n", SERRNO);
+ fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno));
}
int
@@ -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\n", SERRNO);
+ die("select failed: %s\n", strerror(errno));
}
if(FD_ISSET(cmdfd, &rfd)) {
ttyread();