From 775f4f4d6a84a1a5607cfd3d89f15fac9f3747b3 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 7 Dec 2024 11:48:12 +0100 Subject: [PATCH] lib: fix formatting --- src/client/show.c | 5 +++-- src/lib/atom.c | 9 ++++----- src/lib/atom.h | 7 ++++--- src/lib/connection.c | 12 +++++++----- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/client/show.c b/src/client/show.c index fff6fc89..426a9dac 100644 --- a/src/client/show.c +++ b/src/client/show.c @@ -239,8 +239,9 @@ cmd_watch_neighbors(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_en 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; } diff --git a/src/lib/atom.c b/src/lib/atom.c index f5a851c7..a3a60c46 100644 --- a/src/lib/atom.c +++ b/src/lib/atom.c @@ -404,17 +404,16 @@ lldpctl_watch(lldpctl_conn_t *conn) 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; } } diff --git a/src/lib/atom.h b/src/lib/atom.h index c75615c6..387bd533 100644 --- a/src/lib/atom.h +++ b/src/lib/atom.h @@ -30,7 +30,7 @@ struct lldpctl_conn_t { 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 */ @@ -76,8 +76,9 @@ struct lldpctl_conn_t { /* 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); diff --git a/src/lib/connection.c b/src/lib/connection.c index 2c0c0cd9..ce3bc912 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -76,11 +76,11 @@ sync_recv(lldpctl_conn_t *lldpctl, const uint8_t *data, size_t length, void *use 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; } @@ -89,10 +89,11 @@ sync_recv(lldpctl_conn_t *lldpctl, const uint8_t *data, size_t length, void *use /* 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; } @@ -128,7 +129,8 @@ lldpctl_new_name(const char *ctlname, lldpctl_send_callback send, 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; -- 2.39.5