protocol: improve error handling

This commit is contained in:
Wim Taymans 2019-06-19 10:59:00 +02:00
parent 216b641ebb
commit c4f35825fe
2 changed files with 100 additions and 52 deletions

View file

@ -62,13 +62,16 @@ int pw_protocol_native_connect_local_socket(struct pw_protocol_client *client,
if ((runtime_dir = getenv("XDG_RUNTIME_DIR")) == NULL) {
pw_log_error("connect failed: XDG_RUNTIME_DIR not set in the environment");
return -EIO;
res = -EIO;
goto error;
}
name = get_remote(pw_remote_get_properties(remote));
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0)
return -errno;
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
res = -errno;
goto error;
}
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_LOCAL;
@ -94,7 +97,8 @@ int pw_protocol_native_connect_local_socket(struct pw_protocol_client *client,
return res;
error_close:
close(fd);
error_close:
close(fd);
error:
return res;
}