[ds6-devel] nc6/src Makefile.am,1.9,1.10 circ_buf.c,1.14,1.15
circ_buf.h,1.13,1.14 connection.c,1.15,1.16 connection.h,1.6,1.7
filter.c,1.14,1.15 io_stream.c,1.13,1.14 io_stream.h,1.7,1.8
misc.c,1.11,1.12 misc.h,1.13,1.14 netsupport.c,1.4,1.5
network.c,1.26,1.27 parser.c,1.26,1.27 readwrite.c,1.24,1.25
mauro@deepspace6.net
mauro@deepspace6.net
Fri Jan 3 00:14:41 2003
Update of /cvs/nc6/src
Modified Files:
Makefile.am circ_buf.c circ_buf.h connection.c connection.h
filter.c io_stream.c io_stream.h misc.c misc.h netsupport.c
network.c parser.c readwrite.c
Log Message:
started code cleanup for next 0.3 release
Index: Makefile.am
===================================================================
RCS file: /cvs/nc6/src/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile.am 1 Jan 2003 14:03:45 -0000 1.9
+++ Makefile.am 3 Jan 2003 00:14:39 -0000 1.10
@@ -24,7 +24,7 @@
nc6_LDADD = ../contrib/libnc6contrib.a
-CPPFLAGS = -I../contrib
-CFLAGS = @CFLAGS@ @NC6_CFLAGS@
+AM_CPPFLAGS = -I../contrib
+AM_CFLAGS = @CFLAGS@ @NC6_CFLAGS@
MAINTAINERCLEANFILES = Makefile.in config.h.in stamp-h.in
Index: circ_buf.c
===================================================================
RCS file: /cvs/nc6/src/circ_buf.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- circ_buf.c 30 Dec 2002 22:35:46 -0000 1.14
+++ circ_buf.c 3 Jan 2003 00:14:39 -0000 1.15
@@ -51,6 +51,9 @@
void cb_init(circ_buf *cb, size_t size)
{
+ assert(cb != NULL);
+ assert(size > 0);
+
memset(cb, 0, sizeof(circ_buf));
/* normalization: size must be a multiple of 16 */
@@ -68,8 +71,7 @@
void cb_destroy(circ_buf *cb)
{
- assert(cb != NULL);
- assert(cb->buf != NULL);
+ cb_assert(cb);
free(cb->buf);
cb->buf = NULL;
@@ -109,6 +111,7 @@
size_t len;
cb_assert(cb);
+ assert(fd >= 0);
/* buffer is full, return an error condition */
if (cb_is_full(cb)) return -1;
@@ -168,7 +171,7 @@
ssize_t cb_recv(circ_buf *cb, int fd, size_t nbytes,
- struct sockaddr *from, size_t *fromlen)
+ struct sockaddr *from, size_t *fromlen)
{
ssize_t rr;
int count;
@@ -177,6 +180,7 @@
size_t len;
cb_assert(cb);
+ assert(fd >= 0);
/* buffer is full, return an error condition */
if (cb_is_full(cb)) return -1;
@@ -214,10 +218,10 @@
}
}
-
+ /* setup msg structure */
memset(&msg, 0, sizeof(msg));
msg.msg_name = (void *)from;
- msg.msg_namelen = (from && fromlen)? *fromlen : 0;
+ msg.msg_namelen = (from != NULL && fromlen != 0)? *fromlen : 0;
msg.msg_iov = iov;
msg.msg_iovlen = count;
@@ -225,8 +229,10 @@
do {
errno = 0;
rr = recvmsg(fd, &msg, 0);
+
/* copy out updated namelen */
- if (from && fromlen) *fromlen = msg.msg_namelen;
+ if (from != NULL && fromlen != 0)
+ *fromlen = msg.msg_namelen;
} while (errno == EINTR);
/* if rr < 0 an error has occured,
@@ -251,8 +257,8 @@
struct iovec iov[2];
const uint8_t *tmp;
- assert(buf != NULL);
cb_assert(cb);
+ assert(buf != NULL);
/* buffer is full, return an error condition */
if (cb_is_full(cb)) return -1;
@@ -318,6 +324,7 @@
size_t len;
cb_assert(cb);
+ assert(fd >= 0);
/* buffer is empty, return immediately */
if (cb_is_empty(cb)) return 0;
@@ -377,7 +384,7 @@
ssize_t cb_send(circ_buf *cb, int fd, size_t nbytes,
[...41 lines suppressed...]
Index: circ_buf.h
===================================================================
RCS file: /cvs/nc6/src/circ_buf.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- circ_buf.h 30 Dec 2002 22:35:47 -0000 1.13
+++ circ_buf.h 3 Jan 2003 00:14:39 -0000 1.14
@@ -53,11 +53,11 @@
ssize_t cb_read(circ_buf *cb, int fd, size_t nbytes);
ssize_t cb_recv(circ_buf *cb, int fd, size_t nbytes,
- struct sockaddr *from, size_t *fromlen);
+ struct sockaddr *from, size_t *fromlen);
ssize_t cb_write(circ_buf *cb, int fd, size_t nbytes);
ssize_t cb_send(circ_buf *cb, int fd, size_t nbytes,
- struct sockaddr *dest, size_t destlen);
+ struct sockaddr *dest, size_t destlen);
ssize_t cb_append(circ_buf *cb, const uint8_t *buf, size_t len);
ssize_t cb_extract(circ_buf *cb, uint8_t *buf, size_t len);
Index: connection.c
===================================================================
RCS file: /cvs/nc6/src/connection.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- connection.c 1 Jan 2003 13:40:49 -0000 1.15
+++ connection.c 3 Jan 2003 00:14:39 -0000 1.16
@@ -39,24 +39,23 @@
assert(attrs != NULL);
attrs->proto = PROTO_UNSPECIFIED;
- attrs->type = TCP_SOCKET;
+ attrs->type = TCP_SOCKET;
- memset((void*)&(attrs->remote_address), 0,
- sizeof(attrs->remote_address));
- memset((void*)&(attrs->local_address), 0,
- sizeof(attrs->local_address));
+ address_init(&(attrs->remote_address));
+ address_init(&(attrs->local_address));
cb_init(&(attrs->remote_buffer), DEFAULT_BUFFER_SIZE);
- cb_init(&(attrs->local_buffer), DEFAULT_BUFFER_SIZE);
+ cb_init(&(attrs->local_buffer), DEFAULT_BUFFER_SIZE);
/* setup the remote stream to read into the remote buffer and write
* from the local buffer */
io_stream_init(&(attrs->remote_stream), "remote",
- &(attrs->remote_buffer), &(attrs->local_buffer));
+ &(attrs->remote_buffer), &(attrs->local_buffer));
+
/* setup the local stream to read into the local buffer and write
* from the remote buffer */
io_stream_init(&(attrs->local_stream), "local",
- &(attrs->local_buffer), &(attrs->remote_buffer));
+ &(attrs->local_buffer), &(attrs->remote_buffer));
/* the remote stream has an instant hold timeout by default,
* which means that as soon as the remote read stream closes, the
Index: connection.h
===================================================================
RCS file: /cvs/nc6/src/connection.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- connection.h 30 Dec 2002 22:35:47 -0000 1.6
+++ connection.h 3 Jan 2003 00:14:39 -0000 1.7
@@ -43,6 +43,8 @@
char *service;
} address;
+#define address_init(AD) ((AD)->address = (AD)->service = NULL)
+
typedef struct connection_attributes_t
{
sock_proto proto;
@@ -53,9 +55,34 @@
circ_buf local_buffer;
io_stream remote_stream;
io_stream local_stream;
- time_t connect_timeout;
+ int connect_timeout;
} connection_attributes;
+#define ca_set_protocol(CA, PROTO) ((CA)->proto = (PROTO))
+#define ca_set_socket_type(CA, ST) ((CA)->type = (ST))
+#define ca_set_remote_addr(CA, ADDR) ((CA)->remote_address = (ADDR))
+#define ca_set_local_addr(CA, ADDR) ((CA)->local_address = (ADDR))
+
+#define ca_set_MTU(CA, MTU) \
+ ios_set_mtu(&((CA)->remote_stream),(MTU))
+#define ca_set_NRU(CA, NRU) \
+ ios_set_nru(&((CA)->remote_stream),(NRU))
+
+#define ca_set_connection_timeout(CA, CT) \
+ ((CA)->connect_timeout = (CT))
+
+#define ca_supress_half_close_remote(CA) \
+ ios_suppress_half_close(&((CA)->remote_stream), FALSE)
+#define ca_supress_half_close_local(CA) \
+ ios_suppress_half_close(&((CA)->local_stream), FALSE)
+
+#define ca_set_hold_timeout_remote(CA) \
+ ios_set_hold_timeout(&((CA)->remote_stream), -1)
+#define ca_set_hold_timeout_local(CA) \
+ ios_set_hold_timeout(&((CA)->local_stream), -1)
+
+#define ca_resize_local_buf(CA, SIZE) cb_resize(&((CA)->local_buffer),(SIZE))
+#define ca_resize_remote_buf(CA, SIZE) cb_resize(&((CA)->remote_buffer),(SIZE))
void connection_attributes_init(connection_attributes *attrs);
void connection_attributes_destroy(connection_attributes *attrs);
Index: filter.c
===================================================================
RCS file: /cvs/nc6/src/filter.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- filter.c 1 Jan 2003 14:03:45 -0000 1.14
+++ filter.c 3 Jan 2003 00:14:39 -0000 1.15
@@ -55,13 +55,12 @@
bool is_address_ipv4_mapped(const struct sockaddr *a)
{
bool ret = FALSE;
+ const struct sockaddr_in6 *tmp = (const struct sockaddr_in6 *)a;
assert(a != NULL);
if ((a->sa_family == AF_INET6) &&
- IN6_IS_ADDR_V4MAPPED(
- &(((const struct sockaddr_in6 *)a)->sin6_addr)))
- {
+ IN6_IS_ADDR_V4MAPPED(&(tmp->sin6_addr))) {
ret = TRUE;
}
@@ -89,10 +88,10 @@
ap = (struct sockaddr *)alloca(sizeof(struct sockaddr_in));
memset(ap, 0, sizeof(struct sockaddr_in));
memcpy(&(((struct sockaddr_in *)ap)->sin_addr.s_addr),
- &(((const struct sockaddr_in6 *)a)->sin6_addr.s6_addr[12]),
- sizeof(struct in_addr));
+ &(((const struct sockaddr_in6 *)a)->sin6_addr.s6_addr[12]),
+ sizeof(struct in_addr));
((struct sockaddr_in *)ap)->sin_port =
- ((const struct sockaddr_in6 *)a)->sin6_port;
+ ((const struct sockaddr_in6 *)a)->sin6_port;
aa = ap;
}
@@ -101,10 +100,10 @@
bp = (struct sockaddr *)alloca(sizeof(struct sockaddr_in));
memset(bp, 0, sizeof(struct sockaddr_in));
memcpy(&(((struct sockaddr_in *)bp)->sin_addr.s_addr),
- &(((const struct sockaddr_in6 *)b)->sin6_addr.s6_addr[12]),
- sizeof(struct in_addr));
+ &(((const struct sockaddr_in6 *)b)->sin6_addr.s6_addr[12]),
+ sizeof(struct in_addr));
((struct sockaddr_in *)bp)->sin_port =
- ((const struct sockaddr_in6 *)b)->sin6_port;
+ ((const struct sockaddr_in6 *)b)->sin6_port;
bb = bp;
}
#endif
@@ -190,6 +189,7 @@
if (is_flag_set(NUMERIC_MODE) == TRUE)
hints.ai_flags |= AI_NUMERICHOST;
+
hints.ai_flags |= AI_PASSIVE;
err = getaddrinfo(addr->address, addr->service, &hints, &res);
@@ -201,7 +201,7 @@
#ifdef ENABLE_IPV6
if ((is_flag_set(STRICT_IPV6) == TRUE) &&
(is_address_ipv4_mapped(ptr->ai_addr))) {
- /* cannot accept address */
+ /* we cannot accept IPv4-mapped addresses */
continue;
}
#endif
Index: io_stream.c
===================================================================
RCS file: /cvs/nc6/src/io_stream.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- io_stream.c 1 Jan 2003 12:50:58 -0000 1.13
+++ io_stream.c 3 Jan 2003 00:14:39 -0000 1.14
@@ -35,17 +35,17 @@
void io_stream_init(io_stream *ios, const char* name,
- circ_buf *inbuf, circ_buf *outbuf)
+ circ_buf *inbuf, circ_buf *outbuf)
{
assert(ios != NULL);
assert(inbuf != NULL);
assert(outbuf != NULL);
- ios->fd_in = -1;
+ ios->fd_in = -1;
ios->fd_out = -1;
ios->socktype = 0; /* unknown */
- ios->buf_in = inbuf;
+ ios->buf_in = inbuf;
ios->buf_out = outbuf;
ios->mtu = 0; /* unlimited */
@@ -76,7 +76,6 @@
assert(ios != NULL);
assert(fd >= 0);
- /* nonblock(fd); */
ios->fd_in = fd;
ios->fd_out = fd;
ios->socktype = socktype;
@@ -96,9 +95,6 @@
fatal("error in duplicating stdout file descriptor: %s",
strerror(errno));
- /* nonblock(ios->fd_in); */
- /* nonblock(ios->fd_out); */
-
/* pretend stdio is a stream socket */
ios->socktype = SOCK_STREAM;
}
@@ -113,6 +109,7 @@
* the buffer to satisfy the nru, then we can't read */
if ((ios->fd_in < 0) || space == 0 || space < ios->nru)
return -1;
+
/* schedule a read from fdin */
return ios->fd_in;
}
@@ -124,6 +121,7 @@
/* if closed or there is no data in the buffer, then we can't write */
if ((ios->fd_out < 0) || cb_is_empty(ios->buf_out))
return -1;
+
/* schedule a write to fdout */
return ios->fd_out;
}
@@ -166,6 +164,8 @@
{
ssize_t rr;
+ assert(ios != NULL);
+
/* should only be called if ios_schedule_read returned a true result */
assert(ios->fd_in >= 0);
assert(cb_space(ios->buf_in) >= ios->nru);
@@ -188,6 +188,8 @@
{
ssize_t rr;
+ assert(ios != NULL);
+
/* should only be called if ios_schedule_write returned a true result */
assert(ios->fd_out >= 0);
assert(!cb_is_empty(ios->buf_out));
Index: io_stream.h
===================================================================
RCS file: /cvs/nc6/src/io_stream.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- io_stream.h 1 Jan 2003 12:50:58 -0000 1.7
+++ io_stream.h 3 Jan 2003 00:14:39 -0000 1.8
@@ -51,7 +51,7 @@
void io_stream_init(io_stream *ios, const char* name,
- circ_buf *inbuf, circ_buf *outbuf);
+ circ_buf *inbuf, circ_buf *outbuf);
void io_stream_destroy(io_stream *ios);
void ios_assign_socket(io_stream *ios, int fd, int socktype);
@@ -68,7 +68,7 @@
#define ios_suppress_half_close(IOS, B) ((IOS)->half_close_suppress = (B))
/* sets the time (in sec) after read is shutdown that timeout occurs */
-#define ios_set_hold_timeout(IOS, T) ((IOS)->hold_time = (T))
+#define ios_set_hold_timeout(IOS, T) ((IOS)->hold_time = (T))
/* returns an fd if the stream should be scheduled for read, -1 otherwise */
Index: misc.c
===================================================================
RCS file: /cvs/nc6/src/misc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- misc.c 30 Dec 2002 22:35:47 -0000 1.11
+++ misc.c 3 Jan 2003 00:14:39 -0000 1.12
@@ -87,7 +87,7 @@
char *xstrdup(const char *str)
{
- register char *nstr = (char*)xmalloc(strlen(str));
+ register char *nstr = (char *)xmalloc(strlen(str));
/* we should use srtlcpy here instead of strcpy */
strcpy(nstr, str);
return nstr;
Index: misc.h
===================================================================
RCS file: /cvs/nc6/src/misc.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- misc.h 30 Dec 2002 22:35:47 -0000 1.13
+++ misc.h 3 Jan 2003 00:14:39 -0000 1.14
@@ -81,6 +81,8 @@
} while (0)
#endif
+#define istimerexpired(tvp) \
+ (((tvp)->tv_sec || (tvp)->tv_usec) ? FALSE : TRUE)
#ifndef lint
#define RCSID(X) static const char rcsid[] = X
Index: netsupport.c
===================================================================
RCS file: /cvs/nc6/src/netsupport.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- netsupport.c 30 Dec 2002 22:35:47 -0000 1.4
+++ netsupport.c 3 Jan 2003 00:14:39 -0000 1.5
@@ -34,7 +34,7 @@
/* add a new fd/socktype pair to the list */
bound_socket *add_bound_socket(bound_socket *list,
- int fd, int socktype)
+ int fd, int socktype)
{
bound_socket *fdnew;
Index: network.c
===================================================================
RCS file: /cvs/nc6/src/network.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- network.c 1 Jan 2003 14:03:45 -0000 1.26
+++ network.c 3 Jan 2003 00:14:39 -0000 1.27
@@ -102,8 +102,9 @@
#ifdef ENABLE_IPV6
/* skip IPv4 mapped addresses returned from getaddrinfo,
- * for security reasons:
- http://playground.iijlab.net/i-d/draft-itojun-ipv6-transition-abuse-01.txt
+ * for security reasons. see:
+ * http://playground.iijlab.net/i-d/
+ * /draft-itojun-ipv6-transition-abuse-01.txt
*/
if (is_address_ipv4_mapped(ptr->ai_addr))
continue;
@@ -233,7 +234,7 @@
/* set connect timeout */
if (attrs->connect_timeout > 0) {
- tv.tv_sec = attrs->connect_timeout;
+ tv.tv_sec = (time_t)attrs->connect_timeout;
tv.tv_usec = 0;
tvp = &tv;
}
@@ -243,6 +244,7 @@
/* attempt the connection */
err = connect(fd, ptr->ai_addr, ptr->ai_addrlen);
+
if (err != 0 && errno == EINPROGRESS) {
/* connection is proceeding
* it is complete (or failed) when select returns */
@@ -253,12 +255,13 @@
/* call select */
do {
- err = select(
- fd+1, NULL, &connect_fdset, NULL, tvp);
+ err = select(fd + 1, NULL, &connect_fdset,
+ NULL, tvp);
} while (err < 0 && errno == EINTR);
if (err < 0)
fatal("select error: %s", strerror(errno));
+
if (err == 0) {
/* connection timed out */
if (is_flag_set(VERBOSE_MODE) == TRUE) {
@@ -279,12 +282,12 @@
if (err != 0)
errno = err;
}
+
if (err != 0) {
/* connection failed */
if (verbose_mode == TRUE) {
- warn("%s [%s] %s (%s): %s",
- hbuf_rev, hbuf_num,
- sbuf_num, sbuf_rev,
+ warn("cannot connect to %s [%s] %s (%s): %s",
+ hbuf_rev, hbuf_num, sbuf_num, sbuf_rev,
strerror(errno));
}
close(fd);
@@ -364,7 +367,7 @@
numeric_mode = is_flag_set(NUMERIC_MODE);
verbose_mode = is_flag_set(VERBOSE_MODE);
dont_reuse_addr = is_flag_set(DONT_REUSE_ADDR);
- disable_nagle = is_flag_set(DISABLE_NAGLE);
+ disable_nagle = is_flag_set(DISABLE_NAGLE);
/* initialize accept_fdset */
FD_ZERO(&accept_fdset);
@@ -427,8 +430,9 @@
#ifdef ENABLE_IPV6
/* skip IPv4 mapped addresses returned from getaddrinfo,
- * for security reasons:
- http://playground.iijlab.net/i-d/draft-itojun-ipv6-transition-abuse-01.txt
+ * for security reasons. see:
+ * http://playground.iijlab.net/i-d/
+ * /draft-itojun-ipv6-transition-abuse-01.txt
*/
if (is_address_ipv4_mapped(ptr->ai_addr))
continue;
@@ -500,8 +504,7 @@
if (errno == EADDRINUSE &&
ptr->ai_family == PF_INET &&
set_ipv6_only == FALSE &&
- bound_ipv6_any == TRUE)
- {
+ bound_ipv6_any == TRUE) {
warn("listening on %s (%s) ...",
hbuf_num, sbuf_num);
close(fd);
[...19 lines suppressed...]
Index: parser.c
===================================================================
RCS file: /cvs/nc6/src/parser.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- parser.c 1 Jan 2003 15:55:19 -0000 1.26
+++ parser.c 3 Jan 2003 00:14:39 -0000 1.27
@@ -96,7 +96,7 @@
int parse_arguments(int argc, char **argv, connection_attributes *attrs)
{
- int c, verbosity_level = 0;
+ int c, ret, verbosity_level = 0;
bool listen_mode = FALSE;
bool file_transfer = FALSE;
size_t remote_mtu = 0;
@@ -104,15 +104,25 @@
size_t remote_buffer_size = 0;
size_t local_buffer_size = 0;
int option_index = 0;
+ sock_proto protocol;
+ sock_type socket_type;
+ int connect_timeout = -1;
+ address local_address, remote_address;
+ bool half_close = FALSE;
+
+ /* initialize the addresses of the connection endpoints */
+ address_init(&remote_address);
+ address_init(&local_address);
/* set socket types to default values */
- attrs->proto = PROTO_UNSPECIFIED;
- attrs->type = TCP_SOCKET;
+ protocol = PROTO_UNSPECIFIED;
+ socket_type = TCP_SOCKET;
+
+ ret = CONNECT_MODE;
/* option recognition loop */
while ((c = getopt_long(argc, argv, "46hlnp:q:s:uvw:x",
- long_options, &option_index)) >= 0)
- {
+ long_options, &option_index)) >= 0) {
switch(c) {
case 0:
switch(option_index) {
@@ -123,20 +133,19 @@
set_flag(SEND_DATA_ONLY);
break;
case OPT_BUFFER_SIZE:
+ assert(optarg != NULL);
remote_buffer_size = safe_atoi(optarg);
break;
case OPT_MTU:
+ assert(optarg != NULL);
remote_mtu = safe_atoi(optarg);
break;
case OPT_NRU:
+ assert(optarg != NULL);
remote_nru = safe_atoi(optarg);
break;
case OPT_HALF_CLOSE:
- /* keep remote open after half close */
- ios_suppress_half_close(
- &(attrs->remote_stream), FALSE);
- ios_set_hold_timeout(
- &(attrs->remote_stream), -1);
+ half_close = TRUE;
break;
case OPT_DISABLE_NAGLE:
set_flag(DISABLE_NAGLE);
@@ -145,19 +154,19 @@
set_flag(DONT_REUSE_ADDR);
break;
default:
- fatal("getopt returned unexpected "
- "long offset index %d\n", option_index);
+ fatal("getopt returned unexpected long option "
+ "offset index %d\n", option_index);
}
break;
case '4':
- if (attrs->proto != PROTO_UNSPECIFIED)
+ if (protocol != PROTO_UNSPECIFIED)
fatal("cannot specify the address family twice");
- attrs->proto = PROTO_IPv4;
+ protocol = PROTO_IPv4;
break;
case '6':
- if (attrs->proto != PROTO_UNSPECIFIED)
+ if (protocol != PROTO_UNSPECIFIED)
fatal("cannot specify the address family twice");
- attrs->proto = PROTO_IPv6;
+ protocol = PROTO_IPv6;
set_flag(STRICT_IPV6);
break;
case 'h':
@@ -170,21 +179,20 @@
set_flag(NUMERIC_MODE);
[...227 lines suppressed...]
Index: readwrite.c
===================================================================
RCS file: /cvs/nc6/src/readwrite.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- readwrite.c 1 Jan 2003 11:50:08 -0000 1.24
+++ readwrite.c 3 Jan 2003 00:14:39 -0000 1.25
@@ -110,25 +110,26 @@
#ifndef NDEBUG
if (very_verbose_mode == TRUE) {
- if (tvp1)
+ if (tvp1 != NULL)
warn("%s timer expires in %d.%06d",
ios_name(ios1), tv1.tv_sec, tv1.tv_usec);
- if (tvp2)
+ if (tvp2 != NULL)
warn("%s timer expires in %d.%06d",
ios_name(ios2), tv2.tv_sec, tv2.tv_usec);
}
#endif
/* stop loop if either ios has timed out */
- if ((tvp1 && !timerisset(tvp1))||(tvp2 && !timerisset(tvp2))) {
+ if ((tvp1 != NULL && istimerexpired(tvp1) == TRUE) ||
+ (tvp2 != NULL && istimerexpired(tvp2) == TRUE)) {
retval = -1;
break;
}
/* select smallest timeout for select */
- if (tvp1 && tvp2)
- tvp = timercmp(tvp1, tvp2, <)? tvp1 : tvp2;
- else if (tvp1)
+ if (tvp1 != NULL && tvp2 != NULL)
+ tvp = timercmp(tvp1, tvp2, <) ? tvp1 : tvp2;
+ else if (tvp1 != NULL)
tvp = tvp1;
else
tvp = tvp2; /* tvp2 may be NULL */
More information about the ds6-devel
mailing list