char buf[CMSG_SPACE(sizeof(int) * 1)];
} cmsgbuf;
struct iovec iov;
- ssize_t n = -1;
+ ssize_t n;
int fd;
struct imsg_fd *ifd;
return (-1);
}
- if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
+ n = recvmsg(ibuf->fd, &msg, 0);
+ if (n == -1) {
if (errno == EINTR)
goto again;
goto fail;
return (datalen + IMSG_HEADER_SIZE);
}
-int imsg_compose(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, int fd, const void *data, u_int16_t datalen)
+int imsg_compose(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
+ pid_t pid, int fd, const void *data, uint16_t datalen)
{
struct ibuf *wbuf;
return (1);
}
-int imsg_composev(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
+int imsg_composev(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
pid_t pid, int fd, const struct iovec *iov, int iovcnt)
{
struct ibuf *wbuf;
}
/* ARGSUSED */
-struct ibuf *imsg_create(struct imsgbuf *ibuf, u_int32_t type, u_int32_t peerid,
- pid_t pid, u_int16_t datalen)
+struct ibuf *imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
+ pid_t pid, uint16_t datalen)
{
struct ibuf *wbuf;
struct imsg_hdr hdr;
+ memset(&hdr, 0x00, IMSG_HEADER_SIZE);
+
datalen += IMSG_HEADER_SIZE;
if (datalen > MAX_IMSGSIZE) {
errno = ERANGE;
return (wbuf);
}
-int imsg_add(struct ibuf *msg, const void *data, u_int16_t datalen)
+int imsg_add(struct ibuf *msg, const void *data, uint16_t datalen)
{
if (datalen)
if (ibuf_add(msg, data, datalen) == -1) {
if (msg->fd != -1)
hdr->flags |= IMSGF_HASFD;
- hdr->len = (u_int16_t)msg->wpos;
+ hdr->len = (uint16_t)msg->wpos;
ibuf_close(&ibuf->w, msg);
}
int fd;
struct imsg_fd *ifd;
- if ((ifd = TAILQ_FIRST(&ibuf->fds)) == NULL)
+ if ((ifd = TAILQ_POP_FIRST(&ibuf->fds, entry)) == NULL)
return (-1);
fd = ifd->fd;
- TAILQ_REMOVE(&ibuf->fds, ifd, entry);
free(ifd);
return (fd);