Update imsg*.[ch] from OpenBSD, including bzero->memset.

This commit is contained in:
Nicholas Marriott
2015-07-12 19:46:58 +01:00
parent 8b8a007e8e
commit 235e0bd65a
4 changed files with 14 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: imsg.c,v 1.6 2014/06/30 00:26:22 deraadt Exp $ */
/* $OpenBSD: imsg.c,v 1.9 2015/07/12 18:40:49 nicm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -34,12 +34,10 @@ int imsg_get_fd(struct imsgbuf *);
int available_fds(unsigned int);
/* TA: 2014-09-08: Note that the original code calls getdtablecount() which is
* OpenBSD specific. Until such time that it's ported elsewhere from
* <unistd.h>, I've mimicked what OpenSMTPD are doing, by using available_fds()
* instead.
/*
* The original code calls getdtablecount() which is OpenBSD specific. Use
* available_fds() from OpenSMTPD instead.
*/
int
available_fds(unsigned int n)
{
@ -68,7 +66,7 @@ void
imsg_init(struct imsgbuf *ibuf, int fd)
{
msgbuf_init(&ibuf->w);
bzero(&ibuf->r, sizeof(ibuf->r));
memset(&ibuf->r, 0, sizeof(ibuf->r));
ibuf->fd = fd;
ibuf->w.fd = fd;
ibuf->pid = getpid();
@ -89,7 +87,8 @@ imsg_read(struct imsgbuf *ibuf)
int fd;
struct imsg_fd *ifd;
bzero(&msg, sizeof(msg));
memset(&msg, 0, sizeof(msg));
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
iov.iov_base = ibuf->r.buf + ibuf->r.wpos;
iov.iov_len = sizeof(ibuf->r.buf) - ibuf->r.wpos;
@ -317,7 +316,7 @@ int
imsg_flush(struct imsgbuf *ibuf)
{
while (ibuf->w.queued)
if (msgbuf_write(&ibuf->w) < 0)
if (msgbuf_write(&ibuf->w) <= 0)
return (-1);
return (0);
}