From 6b70e99430a0b154245691cb9ff773ee760178da Mon Sep 17 00:00:00 2001 From: piaip Date: Mon, 15 Jun 2009 12:05:31 +0000 Subject: * change toread/towrite's return value to be '-1 for EOF and error'. * make the callers of toread/towrite more robust git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4621 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- common/sys/net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/sys/net.c b/common/sys/net.c index 5bf9dc5e..cf6ca658 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -191,7 +191,8 @@ int toread(int fd, void *buf, int len) if( (l = read(fd, buf, len)) <= 0 ) { if (l < 0 && (errno == EINTR || errno == EAGAIN)) continue; - return l; + // XXX we define toread/towrite as '-1 for EOF and error'. + return -1; // l; }else{ buf += l; len -= l; @@ -209,7 +210,8 @@ int towrite(int fd, const void *buf, int len) if( (l = write(fd, buf, len)) <= 0){ if (l < 0 && (errno == EINTR || errno == EAGAIN)) continue; - return l; + // XXX we define toread/towrite as '-1 for EOF and error'. + return -1; // l; }else{ buf += l; len -= l; -- cgit v1.2.3