diff options
-rw-r--r-- | common/sys/net.c | 6 | ||||
-rw-r--r-- | daemon/utmpd/utmpsync.c | 6 | ||||
-rw-r--r-- | mbbsd/talk.c | 16 |
3 files changed, 15 insertions, 13 deletions
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; diff --git a/daemon/utmpd/utmpsync.c b/daemon/utmpd/utmpsync.c index 53f61ac0..8e74190d 100644 --- a/daemon/utmpd/utmpsync.c +++ b/daemon/utmpd/utmpsync.c @@ -16,11 +16,11 @@ int main(int argc, char **argv) index = -1; towrite(sfd, &index, sizeof(index)); for( i = 0 ; i < USHM_SIZE ; ++i ) - if( towrite(sfd, &SHM->uinfo[i].uid, sizeof(SHM->uinfo[i].uid)) < 0 || + if( towrite(sfd, &SHM->uinfo[i].uid, sizeof(SHM->uinfo[i].uid)) <= 0 || towrite(sfd, SHM->uinfo[i].myfriend, - sizeof(SHM->uinfo[i].myfriend)) < 0 || + sizeof(SHM->uinfo[i].myfriend)) <= 0 || towrite(sfd, SHM->uinfo[i].reject, - sizeof(SHM->uinfo[i].reject)) < 0 ){ + sizeof(SHM->uinfo[i].reject)) <= 0 ){ fprintf(stderr, "sync error %d\n", i); } return 0; diff --git a/mbbsd/talk.c b/mbbsd/talk.c index c3ed6b0b..dae79e40 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -253,14 +253,14 @@ int sync_outta_server(int sfd) ocfs_t fs[MAX_FRIEND*2]; cmd = -2; - if(towrite(sfd, &cmd, sizeof(cmd))<0 || - towrite(sfd, &offset, sizeof(offset))<0 || - towrite(sfd, &currutmp->uid, sizeof(currutmp->uid)) < 0 || - towrite(sfd, currutmp->myfriend, sizeof(currutmp->myfriend))<0 || - towrite(sfd, currutmp->reject, sizeof(currutmp->reject))<0) + if(towrite(sfd, &cmd, sizeof(cmd)) <= 0 || + towrite(sfd, &offset, sizeof(offset)) <= 0 || + towrite(sfd, &currutmp->uid, sizeof(currutmp->uid)) <= 0 || + towrite(sfd, currutmp->myfriend, sizeof(currutmp->myfriend)) <= 0 || + towrite(sfd, currutmp->reject, sizeof(currutmp->reject)) <= 0) return -1; - if(toread(sfd, &res, sizeof(res))<0) + if(toread(sfd, &res, sizeof(res)) <= 0) return -1; if(res<0) @@ -275,14 +275,14 @@ int sync_outta_server(int sfd) exit(0); } - if(toread(sfd, &nfs, sizeof(nfs))<0) + if(toread(sfd, &nfs, sizeof(nfs)) <= 0) return -1; if(nfs<0 || nfs>MAX_FRIEND*2) { fprintf(stderr, "invalid nfs=%d\n",nfs); return -1; } - if(toread(sfd, fs, sizeof(fs[0])*nfs)<0) + if(toread(sfd, fs, sizeof(fs[0])*nfs) <= 0) return -1; close(sfd); |