diff options
author | rsc <devnull@localhost> | 2005-01-04 22:18:54 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-04 22:18:54 +0000 |
commit | 66c10f02c3741400771f92bb98b9df22d3c1abdd (patch) | |
tree | cd787bd274ddaef7eb20d0d9d9aaa730a93fbc21 /src | |
parent | f84eebeb8147a4527cea0ed4839c7c8becfaf8df (diff) | |
download | plan9port-66c10f02c3741400771f92bb98b9df22d3c1abdd.tar.gz plan9port-66c10f02c3741400771f92bb98b9df22d3c1abdd.tar.bz2 plan9port-66c10f02c3741400771f92bb98b9df22d3c1abdd.zip |
avoid duplicated code.
guarantee that EINTR is "interrupted".
Diffstat (limited to 'src')
-rw-r--r-- | src/lib9/errstr.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/lib9/errstr.c b/src/lib9/errstr.c index 578f4895..af989f47 100644 --- a/src/lib9/errstr.c +++ b/src/lib9/errstr.c @@ -36,13 +36,10 @@ errstr(char *err, uint n) char tmp[ERRMAX]; char *syserr; + strecpy(tmp, tmp+ERRMAX, err); + rerrstr(err, n); syserr = getsyserr(); - if(errno != EPLAN9) - strcpy(syserr, strerror(errno)); - - strecpy(tmp, tmp+ERRMAX, syserr); - strecpy(syserr, syserr+ERRMAX, err); - strecpy(err, err+n, tmp); + strecpy(syserr, syserr+ERRMAX, tmp); errno = EPLAN9; return 0; } @@ -53,7 +50,9 @@ rerrstr(char *err, uint n) char *syserr; syserr = getsyserr(); - if(errno != EPLAN9) + if(errno == EINTR) + strcpy(syserr, "interrupted"); + else if(errno != EPLAN9) strcpy(syserr, strerror(errno)); strecpy(err, err+n, syserr); } @@ -80,15 +79,3 @@ werrstr(char *fmt, ...) errstr(buf, ERRMAX); } -char* -gerrstr(void) -{ - char *s; - - s = getsyserr(); - if(errno != EPLAN9) - strcpy(s, strerror(errno)); - return s; -} - - |