Skip to content

Commit

Permalink
timeoute{read,write}: remove the now needless 3rd argument from gener…
Browse files Browse the repository at this point in the history
…ator macros

All instances now use the fd that is passed through the interface, so this can
be removed from the macro.
  • Loading branch information
DerDakon committed Apr 5, 2024
1 parent 5e0f605 commit adf7662
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions qmail-pop3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void die() { _exit(0); }

extern int rename(const char *, const char *);

GEN_SAFE_TIMEOUTREAD(saferead,1200,fd,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,fd,die())
GEN_SAFE_TIMEOUTREAD(saferead,1200,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,die())

char sserrbuf[128];
substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof(sserrbuf));
Expand Down
4 changes: 2 additions & 2 deletions qmail-popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

void _noreturn_ die() { _exit(1); }

GEN_SAFE_TIMEOUTREAD(saferead,1200,fd,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,fd,die())
GEN_SAFE_TIMEOUTREAD(saferead,1200,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,die())

char ssoutbuf[128];
substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
Expand Down
4 changes: 2 additions & 2 deletions qmail-qmqpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void die_format() { _exit(91); }
int lasterror = 55;
int qmqpfd;

GEN_SAFE_TIMEOUTREAD(saferead,60,fd,die_conn())
GEN_SAFE_TIMEOUTWRITE(safewrite,60,fd,die_conn())
GEN_SAFE_TIMEOUTREAD(saferead,60,die_conn())
GEN_SAFE_TIMEOUTWRITE(safewrite,60,die_conn())

char buf[1024];
substdio to = SUBSTDIO_FDBUF(safewrite,-1,buf,sizeof(buf));
Expand Down
4 changes: 2 additions & 2 deletions qmail-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ int timeoutconnect = 60;
int smtpfd;
int timeout = 1200;

GEN_SAFE_TIMEOUTREAD(saferead,timeout,fd,dropped())
GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,fd,dropped())
GEN_SAFE_TIMEOUTREAD(saferead,timeout,dropped())
GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,dropped())

char inbuf[1024];
substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof(inbuf));
Expand Down
2 changes: 1 addition & 1 deletion qmail-smtpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
unsigned int databytes = 0;
int timeout = 1200;

GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,fd,_exit(1))
GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,_exit(1))

char ssoutbuf[512];
substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
Expand Down
4 changes: 2 additions & 2 deletions timeoutread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

extern ssize_t timeoutread(int t, int fd, char *buf, size_t len);

#define GEN_SAFE_TIMEOUTREAD(funcname,tout,readfd,doexit) \
#define GEN_SAFE_TIMEOUTREAD(funcname,tout,doexit) \
ssize_t funcname(int fd, void *buf, size_t len) \
{ \
ssize_t r; \
r = timeoutread(tout,readfd,buf,len); \
r = timeoutread(tout,fd,buf,len); \
if (r == 0 || r == -1) doexit; \
return r; \
}
Expand Down
4 changes: 2 additions & 2 deletions timeoutwrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

extern ssize_t timeoutwrite(int t, int fd, const void *buf, size_t len);

#define GEN_SAFE_TIMEOUTWRITE(funcname,tout,writefd,doexit) \
#define GEN_SAFE_TIMEOUTWRITE(funcname,tout,doexit) \
ssize_t funcname(int fd, const void *buf, size_t len) \
{ \
ssize_t r; \
r = timeoutwrite(tout,writefd,buf,len); \
r = timeoutwrite(tout,fd,buf,len); \
if (r == 0 || r == -1) doexit; \
return r; \
}
Expand Down

0 comments on commit adf7662

Please sign in to comment.