diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2008-10-03 15:20:30 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2008-10-03 15:20:30 +0000 |
commit | 16644455cf8a2cc91cbfb5e57e4ab4588b94246d (patch) | |
tree | 221c2b40239b00ca5cd6b1583661d6505fbc1dbf | |
parent | 9bae92f720d85bb27dece953647f82292e7cda7c (diff) |
Unify code between the various flavors of imsg buffer.c.
Use unsigned int for msg_iovlen.
ok henning@ claudio@
-rw-r--r-- | usr.sbin/bgpd/buffer.c | 8 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/buffer.c | 4 | ||||
-rw-r--r-- | usr.sbin/ospf6d/buffer.c | 4 | ||||
-rw-r--r-- | usr.sbin/ospfd/buffer.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/buffer.c | 12 | ||||
-rw-r--r-- | usr.sbin/snmpd/buffer.c | 12 |
6 files changed, 26 insertions, 18 deletions
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c index a25818cef78..36574934d8e 100644 --- a/usr.sbin/bgpd/buffer.c +++ b/usr.sbin/bgpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.39 2008/03/24 16:11:02 deraadt Exp $ */ +/* $OpenBSD: buffer.c,v 1.40 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -152,13 +152,13 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; struct cmsghdr *cmsg; union { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(int))]; + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; } cmsgbuf; bzero(&iov, sizeof(iov)); diff --git a/usr.sbin/dvmrpd/buffer.c b/usr.sbin/dvmrpd/buffer.c index 751e0ac45eb..055fa2d1b25 100644 --- a/usr.sbin/dvmrpd/buffer.c +++ b/usr.sbin/dvmrpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.1 2006/06/01 14:12:20 norby Exp $ */ +/* $OpenBSD: buffer.c,v 1.2 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -157,7 +157,7 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; diff --git a/usr.sbin/ospf6d/buffer.c b/usr.sbin/ospf6d/buffer.c index 033ea9daef5..6dd9a718f22 100644 --- a/usr.sbin/ospf6d/buffer.c +++ b/usr.sbin/ospf6d/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */ +/* $OpenBSD: buffer.c,v 1.2 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -157,7 +157,7 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; diff --git a/usr.sbin/ospfd/buffer.c b/usr.sbin/ospfd/buffer.c index 636a8e519c6..3d5c69d6623 100644 --- a/usr.sbin/ospfd/buffer.c +++ b/usr.sbin/ospfd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.8 2006/02/10 18:30:47 claudio Exp $ */ +/* $OpenBSD: buffer.c,v 1.9 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -157,7 +157,7 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; diff --git a/usr.sbin/relayd/buffer.c b/usr.sbin/relayd/buffer.c index 5af883d1c8c..56b49937865 100644 --- a/usr.sbin/relayd/buffer.c +++ b/usr.sbin/relayd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.13 2008/05/22 08:35:08 gilles Exp $ */ +/* $OpenBSD: buffer.c,v 1.14 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -155,13 +155,13 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; struct cmsghdr *cmsg; union { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(int))]; + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; } cmsgbuf; bzero(&iov, sizeof(iov)); @@ -202,6 +202,10 @@ msgbuf_write(struct msgbuf *msgbuf) return (-2); } + /* + * assumption: fd got sent if sendmsg sent anything + * this works because fds are passed one at a time + */ if (buf != NULL && buf->fd != -1) { close(buf->fd); buf->fd = -1; diff --git a/usr.sbin/snmpd/buffer.c b/usr.sbin/snmpd/buffer.c index ad0014ddb13..d7f3505bc20 100644 --- a/usr.sbin/snmpd/buffer.c +++ b/usr.sbin/snmpd/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.5 2008/05/22 08:40:03 gilles Exp $ */ +/* $OpenBSD: buffer.c,v 1.6 2008/10/03 15:20:29 eric Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -155,13 +155,13 @@ msgbuf_write(struct msgbuf *msgbuf) { struct iovec iov[IOV_MAX]; struct buf *buf, *next; - int i = 0; + unsigned int i = 0; ssize_t n; struct msghdr msg; struct cmsghdr *cmsg; union { - struct cmsghdr hdr; - char buf[CMSG_SPACE(sizeof(int))]; + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; } cmsgbuf; bzero(&iov, sizeof(iov)); @@ -202,6 +202,10 @@ msgbuf_write(struct msgbuf *msgbuf) return (-2); } + /* + * assumption: fd got sent if sendmsg sent anything + * this works because fds are passed one at a time + */ if (buf != NULL && buf->fd != -1) { close(buf->fd); buf->fd = -1; |