]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/imsg.c
Merge pull request #3899 from ton31337/fix/remove_private_as_with_local_as
[mirror_frr.git] / lib / imsg.c
index 6419f805abb57c6ed2f568d4ccf05e1dfe29cff1..f07c56f0a64500b009fe6fa9766bc1f4b51b9abf 100644 (file)
 
 #include <zebra.h>
 
+#include "memory.h"
 #include "queue.h"
 #include "imsg.h"
 
-int imsg_fd_overhead = 0;
+static int imsg_fd_overhead = 0;
 
-int imsg_get_fd(struct imsgbuf *);
+static int imsg_get_fd(struct imsgbuf *);
 
 #ifndef __OpenBSD__
 /*
@@ -35,7 +36,7 @@ static int available_fds(unsigned int n)
        unsigned int i;
        int ret, fds[256];
 
-       if (n > (sizeof(fds) / sizeof(fds[0])))
+       if (n > (unsigned int)array_size(fds))
                return (1);
 
        ret = 0;
@@ -77,7 +78,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 +111,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;
@@ -298,11 +300,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);