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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user