while (1) {
if (lldpctl_watch(conn) < 0) {
if (lldpctl_last_error(conn) != LLDPCTL_ERR_CALLBACK_UNBLOCK) {
- log_warnx("lldpctl", "unable to watch for neighbors. %s",
- lldpctl_last_strerror(conn));
+ log_warnx("lldpctl",
+ "unable to watch for neighbors. %s",
+ lldpctl_last_strerror(conn));
}
return 0;
}
void
lldpctl_watch_sync_unblock(lldpctl_conn_t *conn)
{
- if (conn->state != CONN_STATE_WATCHING)
- return;
+ if (conn->state != CONN_STATE_WATCHING) return;
- if (!conn->sync_clb)
- return;
+ if (!conn->sync_clb) return;
struct lldpctl_conn_sync_t *data = conn->user_data;
if (data->pipe_fd[1] != -1) {
/* Write to the pipe to unblock the read */
- write(data->pipe_fd[1], "x", 1);
+ ssize_t rc = write(data->pipe_fd[1], "x", 1);
+ (void)rc;
}
}
lldpctl_recv_callback recv; /* Receive callback */
lldpctl_send_callback send; /* Send callback */
void *user_data; /* Callback user data */
- uint8_t sync_clb; /* If set synchronous callbacks are used */
+ uint8_t sync_clb; /* If set synchronous callbacks are used */
/* IO state handling. */
uint8_t *input_buffer; /* Current input/output buffer */
/* User data for synchronous callbacks. */
struct lldpctl_conn_sync_t {
- int fd; /* File descriptor to the socket. */
- int pipe_fd[2]; /* Pipe file descriptors required for unblocking a read-blocked watcher. */
+ int fd; /* File descriptor to the socket. */
+ int pipe_fd[2]; /* Pipe file descriptors required for unblocking a read-blocked
+ watcher. */
};
ssize_t _lldpctl_needs(lldpctl_conn_t *lldpctl, size_t length);
fds[0].fd = conn->pipe_fd[0];
fds[0].events = POLLIN;
fds[1].fd = conn->fd;
- fds[1].events = POLLIN;
+ fds[1].events = POLLIN;
remain = length;
do {
- if (poll(fds, sizeof(fds)/sizeof(fds[0]), -1) == -1) {
+ if (poll(fds, sizeof(fds) / sizeof(fds[0]), -1) == -1) {
if (errno == EINTR) continue;
return LLDPCTL_ERR_CALLBACK_FAILURE;
}
/* Unblock request received. */
return LLDPCTL_ERR_CALLBACK_UNBLOCK;
}
-
+
if (fds[1].revents & POLLIN) {
/* Message from daemon. */
- if ((nb = read(conn->fd, (unsigned char *)data + offset, remain)) == -1) {
+ if ((nb = read(conn->fd, (unsigned char *)data + offset,
+ remain)) == -1) {
if (errno == EAGAIN || errno == EINTR) continue;
return LLDPCTL_ERR_CALLBACK_FAILURE;
}
goto end;
}
if (!send && !recv) {
- if ((data = malloc(sizeof(struct lldpctl_conn_sync_t))) == NULL) goto end;
+ if ((data = malloc(sizeof(struct lldpctl_conn_sync_t))) == NULL)
+ goto end;
if (pipe(data->pipe_fd) == -1) goto end;
data->fd = -1;
conn->send = sync_send;