diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-07-12 19:46:58 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-07-12 19:46:58 +0100 |
commit | 235e0bd65a49b469d661a9831067e3f745fbbaad (patch) | |
tree | 8ecc41212fd73d598e126488913c0a3efeb6c9f8 /compat/imsg.c | |
parent | 8b8a007e8e1faa6af20acdeac728c4fddfeb2f6b (diff) | |
download | rtmux-235e0bd65a49b469d661a9831067e3f745fbbaad.tar.gz rtmux-235e0bd65a49b469d661a9831067e3f745fbbaad.tar.bz2 rtmux-235e0bd65a49b469d661a9831067e3f745fbbaad.zip |
Update imsg*.[ch] from OpenBSD, including bzero->memset.
Diffstat (limited to 'compat/imsg.c')
-rw-r--r-- | compat/imsg.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compat/imsg.c b/compat/imsg.c index 9db26ad6..982ee069 100644 --- a/compat/imsg.c +++ b/compat/imsg.c @@ -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); } |