summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r--src/libsystemd/sd-bus/bus-container.c6
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c26
-rw-r--r--src/libsystemd/sd-bus/bus-message.c4
-rw-r--r--src/libsystemd/sd-bus/bus-socket.c4
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c4
-rw-r--r--src/libsystemd/sd-bus/sd-memfd.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-kernel-benchmark.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-kernel.c6
9 files changed, 27 insertions, 31 deletions
diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c
index d330363b6f..2cd0e1f99e 100644
--- a/src/libsystemd/sd-bus/bus-container.c
+++ b/src/libsystemd/sd-bus/bus-container.c
@@ -154,8 +154,7 @@ int bus_container_connect_kernel(sd_bus *b) {
if (child == 0) {
pid_t grandchild;
- close_nointr_nofail(pair[0]);
- pair[0] = -1;
+ pair[0] = safe_close(pair[0]);
r = namespace_enter(pidnsfd, mntnsfd, rootfd);
if (r < 0)
@@ -202,8 +201,7 @@ int bus_container_connect_kernel(sd_bus *b) {
_exit(si.si_status);
}
- close_nointr_nofail(pair[1]);
- pair[1] = -1;
+ pair[1] = safe_close(pair[1]);
r = wait_for_terminate(child, &si);
if (r < 0)
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 5c955f4a07..e229baf266 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -811,7 +811,7 @@ static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
if (d->type == KDBUS_ITEM_FDS)
close_many(d->fds, (d->size - offsetof(struct kdbus_item, fds)) / sizeof(int));
else if (d->type == KDBUS_ITEM_PAYLOAD_MEMFD)
- close_nointr_nofail(d->memfd.fd);
+ safe_close(d->memfd.fd);
}
}
@@ -1165,7 +1165,7 @@ static void close_and_munmap(int fd, void *address, size_t size) {
if (size > 0)
assert_se(munmap(address, PAGE_ALIGN(size)) >= 0);
- close_nointr_nofail(fd);
+ safe_close(fd);
}
void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, size_t allocated) {
@@ -1313,14 +1313,14 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
make->flags = world ? KDBUS_MAKE_ACCESS_WORLD : 0;
if (ioctl(fd, KDBUS_CMD_BUS_MAKE, make) < 0) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -errno;
}
/* The higher 32bit of the flags field are considered
* 'incompatible flags'. Refuse them all for now. */
if (make->flags > 0xFFFFFFFFULL) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOTSUP;
}
@@ -1329,7 +1329,7 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
p = strjoin("/dev/kdbus/", n->str, "/bus", NULL);
if (!p) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOMEM;
}
@@ -1424,7 +1424,7 @@ int bus_kernel_create_starter(const char *bus, const char *name, BusNamePolicy *
hello->pool_size = KDBUS_POOL_SIZE;
if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -errno;
}
@@ -1432,12 +1432,12 @@ int bus_kernel_create_starter(const char *bus, const char *name, BusNamePolicy *
* 'incompatible flags'. Refuse them all for now. */
if (hello->bus_flags > 0xFFFFFFFFULL ||
hello->conn_flags > 0xFFFFFFFFULL) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOTSUP;
}
if (!bloom_validate_parameters((size_t) hello->bloom.size, (unsigned) hello->bloom.n_hash)) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOTSUP;
}
@@ -1469,14 +1469,14 @@ int bus_kernel_create_domain(const char *name, char **s) {
make->flags = KDBUS_MAKE_ACCESS_WORLD;
if (ioctl(fd, KDBUS_CMD_DOMAIN_MAKE, make) < 0) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -errno;
}
/* The higher 32bit of the flags field are considered
* 'incompatible flags'. Refuse them all for now. */
if (make->flags > 0xFFFFFFFFULL) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOTSUP;
}
@@ -1485,7 +1485,7 @@ int bus_kernel_create_domain(const char *name, char **s) {
p = strappend("/dev/kdbus/domain/", name);
if (!p) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOMEM;
}
@@ -1515,7 +1515,7 @@ int bus_kernel_create_monitor(const char *bus) {
hello->pool_size = KDBUS_POOL_SIZE;
if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -errno;
}
@@ -1523,7 +1523,7 @@ int bus_kernel_create_monitor(const char *bus) {
* 'incompatible flags'. Refuse them all for now. */
if (hello->bus_flags > 0xFFFFFFFFULL ||
hello->conn_flags > 0xFFFFFFFFULL) {
- close_nointr_nofail(fd);
+ safe_close(fd);
return -ENOTSUP;
}
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index e32f2b827f..4fcc693543 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -70,7 +70,7 @@ static void message_free_part(sd_bus_message *m, struct bus_body_part *part) {
if (part->mapped > 0)
assert_se(munmap(part->data, part->mapped) == 0);
- close_nointr_nofail(part->memfd);
+ safe_close(part->memfd);
}
} else if (part->munmap_this)
@@ -1274,7 +1274,7 @@ static int message_push_fd(sd_bus_message *m, int fd) {
f = realloc(m->fds, sizeof(int) * (m->n_fds + 1));
if (!f) {
m->poisoned = true;
- close_nointr_nofail(copy);
+ safe_close(copy);
return -ENOMEM;
}
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index 016f8a1c9f..bccf501222 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -750,7 +750,7 @@ int bus_socket_exec(sd_bus *b) {
assert_se(dup3(s[1], STDOUT_FILENO, 0) == STDOUT_FILENO);
if (s[1] != STDIN_FILENO && s[1] != STDOUT_FILENO)
- close_nointr_nofail(s[1]);
+ safe_close(s[1]);
fd_cloexec(STDIN_FILENO, false);
fd_cloexec(STDOUT_FILENO, false);
@@ -767,7 +767,7 @@ int bus_socket_exec(sd_bus *b) {
_exit(EXIT_FAILURE);
}
- close_nointr_nofail(s[1]);
+ safe_close(s[1]);
b->output_fd = b->input_fd = s[0];
bus_socket_setup(b);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index ba8a8a244a..2794a4483f 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -63,10 +63,10 @@ static void bus_close_fds(sd_bus *b) {
detach_io_events(b);
if (b->input_fd >= 0)
- close_nointr_nofail(b->input_fd);
+ safe_close(b->input_fd);
if (b->output_fd >= 0 && b->output_fd != b->input_fd)
- close_nointr_nofail(b->output_fd);
+ safe_close(b->output_fd);
b->input_fd = b->output_fd = -1;
}
diff --git a/src/libsystemd/sd-bus/sd-memfd.c b/src/libsystemd/sd-bus/sd-memfd.c
index 8f9e236392..fcf3e73124 100644
--- a/src/libsystemd/sd-bus/sd-memfd.c
+++ b/src/libsystemd/sd-bus/sd-memfd.c
@@ -107,7 +107,7 @@ _public_ int sd_memfd_new(sd_memfd **m, const char *name) {
n = new0(struct sd_memfd, 1);
if (!n) {
- close_nointr_nofail(cmd->fd);
+ safe_close(cmd->fd);
return -ENOMEM;
}
@@ -144,7 +144,7 @@ _public_ void sd_memfd_free(sd_memfd *m) {
if (m->f)
fclose(m->f);
else
- close_nointr_nofail(m->fd);
+ safe_close(m->fd);
free(m);
}
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 113d15ba97..1b9d98fa75 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -232,7 +232,7 @@ static int server(sd_bus *bus) {
if (write(fd, &x, 1) < 0) {
log_error("Failed to write to fd: %m");
- close_nointr_nofail(fd);
+ safe_close(fd);
goto fail;
}
diff --git a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
index bfeee59d2f..90257d4f3c 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
@@ -270,7 +270,7 @@ int main(int argc, char *argv[]) {
CPU_SET(0, &cpuset);
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
- close_nointr_nofail(bus_ref);
+ safe_close(bus_ref);
sd_bus_unref(b);
switch (mode) {
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 2f0f5aa00b..34d000f1c6 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -137,14 +137,12 @@ int main(int argc, char *argv[]) {
assert_se(write(pipe_fds[1], "x", 1) == 1);
- close_nointr_nofail(pipe_fds[1]);
- pipe_fds[1] = -1;
+ pipe_fds[1] = safe_close(pipe_fds[1]);
r = sd_bus_message_append(m, "h", pipe_fds[0]);
assert_se(r >= 0);
- close_nointr_nofail(pipe_fds[0]);
- pipe_fds[0] = -1;
+ pipe_fds[0] = safe_close(pipe_fds[0]);
r = sd_bus_send(b, m, NULL);
assert_se(r >= 0);