diff options
author | Jakub Janků <jjanku@redhat.com> | 2018-09-04 18:40:47 +0200 |
---|---|---|
committer | Victor Toso <me@victortoso.com> | 2018-09-07 16:59:52 +0200 |
commit | 27aa50e6298aa259c31d6abbd76eb351702ceb77 (patch) | |
tree | 08b05f925fcf8fe2a6069847452fa0b3491f8b81 /src | |
parent | 061593ed855e4e47d6601e0720498ffd5ea93ad1 (diff) |
udscs: return void in udscs_write{, _all}()
The functions would return -1 only if malloc() failed, otherwise 0.
Since malloc() was replaced by g_malloc(), which terminates
the program if the allocation fails, return void instead.
Signed-off-by: Jakub Janků <jjanku@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/udscs.c | 13 | ||||
-rw-r--r-- | src/udscs.h | 5 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/udscs.c b/src/udscs.c index 31643e9..59e24d8 100644 --- a/src/udscs.c +++ b/src/udscs.c @@ -183,7 +183,7 @@ void *udscs_get_user_data(struct udscs_connection *conn) return conn->user_data; } -int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, +void udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size) { struct udscs_buf *wbuf, *new_wbuf; @@ -222,7 +222,7 @@ int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, if (!conn->write_buf) { conn->write_buf = new_wbuf; - return 0; + return; } /* maybe we should limit the write_buf stack depth ? */ @@ -231,8 +231,6 @@ int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, wbuf = wbuf->next; wbuf->next = new_wbuf; - - return 0; } /* A helper for udscs_do_read() */ @@ -574,7 +572,7 @@ void udscs_server_handle_fds(struct udscs_server *server, fd_set *readfds, } } -int udscs_server_write_all(struct udscs_server *server, +void udscs_server_write_all(struct udscs_server *server, uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size) { @@ -582,12 +580,9 @@ int udscs_server_write_all(struct udscs_server *server, conn = server->connections_head.next; while (conn) { - if (udscs_write(conn, type, arg1, arg2, data, size)) - return -1; + udscs_write(conn, type, arg1, arg2, data, size); conn = conn->next; } - - return 0; } int udscs_server_for_all_clients(struct udscs_server *server, diff --git a/src/udscs.h b/src/udscs.h index 4f47b7f..a863e16 100644 --- a/src/udscs.h +++ b/src/udscs.h @@ -79,9 +79,8 @@ struct udscs_connection *udscs_connect(const char *socketname, void udscs_destroy_connection(struct udscs_connection **connp); /* Queue a message for delivery to the client connected through conn. - * Return value: 0 on success -1 on error (only happens when malloc fails). */ -int udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, +void udscs_write(struct udscs_connection *conn, uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size); /* Associates the specified user data with the connection. */ @@ -141,7 +140,7 @@ void udscs_destroy_server(struct udscs_server *server); /* Like udscs_write, but then send the message to all clients connected to * the server. */ -int udscs_server_write_all(struct udscs_server *server, +void udscs_server_write_all(struct udscs_server *server, uint32_t type, uint32_t arg1, uint32_t arg2, const uint8_t *data, uint32_t size); |