]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/imsg.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / imsg.c
index 0ea1dd6302bbbe6be333db6da64b5d9549994c24..935d13772752a2a668fc4d9699793c4addd7845a 100644 (file)
@@ -77,7 +77,7 @@ ssize_t imsg_read(struct imsgbuf *ibuf)
                char buf[CMSG_SPACE(sizeof(int) * 1)];
        } cmsgbuf;
        struct iovec iov;
-       ssize_t n = -1;
+       ssize_t n;
        int fd;
        struct imsg_fd *ifd;
 
@@ -110,7 +110,8 @@ again:
                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;
@@ -241,6 +242,8 @@ struct ibuf *imsg_create(struct imsgbuf *ibuf, uint32_t type, uint32_t peerid,
        struct ibuf *wbuf;
        struct imsg_hdr hdr;
 
+       memset(&hdr, 0x00, IMSG_HEADER_SIZE);
+
        datalen += IMSG_HEADER_SIZE;
        if (datalen > MAX_IMSGSIZE) {
                errno = ERANGE;
@@ -296,11 +299,10 @@ int imsg_get_fd(struct imsgbuf *ibuf)
        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);