mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Update imsg*.[ch] from OpenBSD, including bzero->memset.
This commit is contained in:
parent
8b8a007e8e
commit
235e0bd65a
5
compat.h
5
compat.h
@ -185,11 +185,6 @@ typedef uint64_t u_int64_t;
|
||||
#define flock(fd, op) (0)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BZERO
|
||||
#undef bzero
|
||||
#define bzero(buf, len) memset(buf, 0, len);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CLOSEFROM
|
||||
/* closefrom.c */
|
||||
void closefrom(int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: imsg-buffer.c,v 1.4 2014/06/30 00:25:17 deraadt Exp $ */
|
||||
/* $OpenBSD: imsg-buffer.c,v 1.7 2015/07/12 18:40:49 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
|
||||
@ -74,7 +74,7 @@ ibuf_realloc(struct ibuf *buf, size_t len)
|
||||
|
||||
/* on static buffers max is eq size and so the following fails */
|
||||
if (buf->wpos + len > buf->max) {
|
||||
errno = ENOMEM;
|
||||
errno = ERANGE;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ ibuf_write(struct msgbuf *msgbuf)
|
||||
unsigned int i = 0;
|
||||
ssize_t n;
|
||||
|
||||
bzero(&iov, sizeof(iov));
|
||||
memset(&iov, 0, sizeof(iov));
|
||||
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
|
||||
if (i >= IOV_MAX)
|
||||
break;
|
||||
@ -233,8 +233,9 @@ msgbuf_write(struct msgbuf *msgbuf)
|
||||
char buf[CMSG_SPACE(sizeof(int))];
|
||||
} cmsgbuf;
|
||||
|
||||
bzero(&iov, sizeof(iov));
|
||||
bzero(&msg, sizeof(msg));
|
||||
memset(&iov, 0, sizeof(iov));
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
|
||||
TAILQ_FOREACH(buf, &msgbuf->bufs, entry) {
|
||||
if (i >= IOV_MAX)
|
||||
break;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -99,7 +99,6 @@ AC_CHECK_HEADERS(
|
||||
# Check for some functions that are replaced or omitted.
|
||||
AC_CHECK_FUNCS(
|
||||
[ \
|
||||
bzero \
|
||||
dirfd \
|
||||
flock \
|
||||
setproctitle \
|
||||
|
Loading…
Reference in New Issue
Block a user