summaryrefslogtreecommitdiffstats
path: root/src/socket-proxy
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-06-05 15:12:29 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-06-22 16:32:37 +0200
commitde7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b (patch)
treeead57ab4a03ef723497b65d0efd79ea8973aaaed /src/socket-proxy
parentbasic/set: add set_ensure_put() (diff)
downloadsystemd-de7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b.tar.xz
systemd-de7fef4b6eb4f5ca1cd21a309c37d0a74d4d305b.zip
tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many parts were converted by hand. Note: I did not fix errors in return value handing. This will be done separate to keep the patch comprehensible. No functional change is intended in this patch.
Diffstat (limited to 'src/socket-proxy')
-rw-r--r--src/socket-proxy/socket-proxyd.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 7b548c5076..3b7c5799c8 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -480,12 +480,6 @@ static int add_connection_socket(Context *context, int fd) {
log_warning_errno(r, "Unable to disable idle timer, continuing: %m");
}
- r = set_ensure_allocated(&context->connections, NULL);
- if (r < 0) {
- log_oom();
- return 0;
- }
-
c = new0(Connection, 1);
if (!c) {
log_oom();
@@ -498,7 +492,7 @@ static int add_connection_socket(Context *context, int fd) {
c->server_to_client_buffer[0] = c->server_to_client_buffer[1] = -1;
c->client_to_server_buffer[0] = c->client_to_server_buffer[1] = -1;
- r = set_put(context->connections, c);
+ r = set_ensure_put(&context->connections, NULL, c);
if (r < 0) {
free(c);
log_oom();
@@ -550,12 +544,6 @@ static int add_listen_socket(Context *context, int fd) {
assert(context);
assert(fd >= 0);
- r = set_ensure_allocated(&context->listen, NULL);
- if (r < 0) {
- log_oom();
- return r;
- }
-
r = sd_is_socket(fd, 0, SOCK_STREAM, 1);
if (r < 0)
return log_error_errno(r, "Failed to determine socket type: %m");
@@ -571,7 +559,7 @@ static int add_listen_socket(Context *context, int fd) {
if (r < 0)
return log_error_errno(r, "Failed to add event source: %m");
- r = set_put(context->listen, source);
+ r = set_ensure_put(&context->listen, NULL, source);
if (r < 0) {
log_error_errno(r, "Failed to add source to set: %m");
sd_event_source_unref(source);