mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
sd-varlink: unify AF_UNIX check in sd_varlink_set_allow_fd_passing_output()
Currently, the socket type is only checked if the fd passing is being enabled. The special handling seems unnecessary though, as in the disable case, either fd passing is already false and would be caught by the (... == !!b) shortcut at the beginning, or the AF_UNIX check wouldn't have succeeded in the first place, for the initial toggle to true. Hence, just uniformly check AF_UNIX. While at it, sd_varlink_set_allow_fd_passing_*() oddly return 1 iff changed and !b, which doesn't fit into our coding style and I can't come up with any use case for such behavior. Let's return 1 on changed and 0 otherwise. sd_varlink_set_allow_fd_passing_input() will be fixed in the later commits with other enhancements.
This commit is contained in:
@@ -3271,17 +3271,12 @@ _public_ int sd_varlink_set_allow_fd_passing_output(sd_varlink *v, int b) {
|
||||
if (v->allow_fd_passing_output == !!b)
|
||||
return 0;
|
||||
|
||||
if (!b) {
|
||||
v->allow_fd_passing_output = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
r = verify_unix_socket(v);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
v->allow_fd_passing_output = true;
|
||||
return 0;
|
||||
v->allow_fd_passing_output = !!b;
|
||||
return 1;
|
||||
}
|
||||
|
||||
_public_ int sd_varlink_set_input_sensitive(sd_varlink *v) {
|
||||
|
||||
Reference in New Issue
Block a user