Commit 5a100571 authored by Justin Mitchell's avatar Justin Mitchell
Browse files

Replace all uses of bzero(3) as it is deprecated.

parent a7dff10a
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -345,9 +345,8 @@ void catchdoing(const char *what)
/* block handling functions */
struct block_t * block_new(int size)
{
	struct block_t *new = malloc(sizeof(struct block_t));
	new->p_buffer = malloc(size);
	bzero(new->p_buffer, size);
	struct block_t *new = calloc(1, sizeof(struct block_t));
	new->p_buffer = calloc(1, size);
	new->i_size = size;
	new->i_used = 0;
	new->p_cursor = new->p_buffer;
+6 −6
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ int poll_addconn(ipc_connection_t *conn)
	struct epoll_event ev;
	int ret;

	bzero(&ev, sizeof(ev));
	memset(&ev, 0, sizeof(ev));
	ev.events = EPOLLIN | EPOLLERR;
	ev.data.ptr = conn;
	ret = epoll_ctl(ep.pollfd, EPOLL_CTL_ADD, conn->fd, &ev);
@@ -35,7 +35,7 @@ void poll_delete(int fd)
{
	struct epoll_event ev;

	bzero(&ev, sizeof(ev));
	memset(&ev, 0, sizeof(ev));
	epoll_ctl(ep.pollfd, EPOLL_CTL_DEL, fd, &ev);
}

@@ -43,7 +43,7 @@ int poll_with_writes(ipc_connection_t *conn)
{
	struct epoll_event ev;

	bzero(&ev, sizeof(ev));
	memset(&ev, 0, sizeof(ev));
	ev.events = EPOLLIN | EPOLLOUT | EPOLLERR;
	ev.data.ptr = conn;
	return epoll_ctl(ep.pollfd, EPOLL_CTL_MOD, conn->fd, &ev);
@@ -53,7 +53,7 @@ int poll_without_writes(ipc_connection_t *conn)
{
	struct epoll_event ev;

	bzero(&ev, sizeof(ev));
	memset(&ev, 0, sizeof(ev));
	ev.events = EPOLLIN | EPOLLERR;
	ev.data.ptr = conn;
	return epoll_ctl(ep.pollfd, EPOLL_CTL_MOD, conn->fd, &ev);
@@ -63,7 +63,7 @@ int poll_fd_without_writes(int fd)
{
	struct epoll_event ev;

	bzero(&ev, sizeof(ev));
	memset(&ev, 0, sizeof(ev));
	ev.events = EPOLLIN | EPOLLERR;
	ev.data.ptr = NULL;
	return epoll_ctl(ep.pollfd, EPOLL_CTL_ADD, fd, &ev);
@@ -80,7 +80,7 @@ int poll_wait(int timeout_millis, int (*callback)(poll_event_t *, int, void *),
	if (ret < 0)
		return ret;
	for (int i = 0; i < ret; i++) {
		bzero(&pevs[i], sizeof(pevs[i]));
		memset(&pevs[i], 0, sizeof(pevs[i]));
		pevs[i].data = evs[i].data.ptr;
		pevs[i].is_error = (evs[i].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP));
		pevs[i].is_read = (evs[i].events & (EPOLLIN | EPOLLPRI));
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ int poll_wait(int timeout_millis, int (*callback)(poll_event_t *, int, void *),
	if (ret == -1)
		return ret;
	for (int i = 0; i < ret; i++) {
		bzero(&pevs[i], sizeof(pevs[i]));
		memset(&pevs[i], 0, sizeof(pevs[i]));
		pevs[i].data = evs[i].udata;
		pevs[i].is_error = (evs[i].flags & (EV_EOF | EV_ERROR));
		pevs[i].is_read = (evs[i].filter == EVFILT_READ);
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ void drop_connection(ipc_connection_t * conn)
			free(oq);
		}
	}
	bzero(conn, sizeof(ipc_connection_t));
	memset(conn, 0, sizeof(ipc_connection_t));
	free(conn);

	ipc_message_t * whoinfo = msg_wholist();
+6 −9
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@
/* create an empty message */
ipc_message_t * ipcmsg_create(uint32_t type, uint32_t src)
{
	ipc_message_t *new = malloc(sizeof(ipc_message_t));
	bzero(new, sizeof(ipc_message_t));
	ipc_message_t *new = calloc(1, sizeof(ipc_message_t));
	new->head.src = src;
	new->head.type = type;
	return new;
@@ -57,7 +56,7 @@ void ipcmsg_destroy(ipc_message_t * msg)
	if (msg->refcount > 0) return;

	if (msg->body != NULL) free(msg->body);
	bzero(msg, sizeof(ipc_message_t));
	memset(msg, 0, sizeof(ipc_message_t));
	free(msg);
}

@@ -65,8 +64,7 @@ int msg_queue(ipc_message_t *msg, ipc_connection_t *conn)
{
	int wasempty = list_empty(&conn->outq);

	outq_msg_t * new = malloc(sizeof(outq_msg_t));
	bzero(new, sizeof(outq_msg_t));
	outq_msg_t * new = calloc(1, sizeof(outq_msg_t));
	new->msg = msg;
	new->msg->refcount++;
	list_add_tail(&(new->list), &(conn->outq));
@@ -89,7 +87,7 @@ void ipcmsg_send(ipc_message_t *msg, ipc_connection_t *conn)
	if (msg == NULL) { msg_queue(msg, conn); return; }
	if (conn->fd == -1) { msg_queue(msg, conn); return; }

	bzero(&iov, sizeof(iov));
	memset(&iov, 0, sizeof(iov));
	iov[0].iov_base = &msg->head;
	iov[0].iov_len = sizeof(msg->head);
	iovused++;
@@ -122,8 +120,7 @@ void ipcconn_bad(ipc_connection_t * conn)
/* create an empty connection socket struct */
ipc_connection_t * ipcconn_create(void)
{
	ipc_connection_t * conn = malloc(sizeof(ipc_connection_t));
	bzero(conn, sizeof(ipc_connection_t));
	ipc_connection_t * conn = calloc(1, sizeof(ipc_connection_t));
	conn->fd = -1;
	conn->state = IPCSTATE_ERROR;
	INIT_LIST_HEAD(&(conn->outq));
@@ -149,7 +146,7 @@ int ipcconn_connect(const char * target)
		snprintf(port, 6, "%d", IPCPORT_DEFAULT);
	}

	bzero(&hint, sizeof(hint));
	memset(&hint, 0, sizeof(hint));
	hint.ai_family = AF_INET;
	hint.ai_socktype = SOCK_STREAM;
	hint.ai_protocol = IPPROTO_TCP;
Loading