/src/systemd/src/libsystemd/sd-bus/bus-kernel.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
2 | | |
3 | | #include <sys/mman.h> |
4 | | |
5 | | #include "bus-kernel.h" |
6 | | #include "bus-internal.h" |
7 | | #include "fd-util.h" |
8 | | #include "memory-util.h" |
9 | | |
10 | 0 | void close_and_munmap(int fd, void *address, size_t size) { |
11 | 0 | if (size > 0) { |
12 | 0 | size = PAGE_ALIGN(size); |
13 | 0 | assert(size < SIZE_MAX); |
14 | 0 | assert_se(munmap(address, size) >= 0); |
15 | 0 | } |
16 | |
|
17 | 0 | safe_close(fd); |
18 | 0 | } |
19 | | |
20 | 10.3k | void bus_flush_memfd(sd_bus *b) { |
21 | 10.3k | assert(b); |
22 | | |
23 | 10.3k | for (unsigned i = 0; i < b->n_memfd_cache; i++) |
24 | 0 | close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped); |
25 | 10.3k | } |