summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/test-bus-watch-bind.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-15 13:58:31 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-15 19:40:51 +0200
commit15a3e96f9220c931507456764902ff05d7171318 (patch)
treecd669f3363875fe1ee98a4bbcd77f1c27ca30f5e /src/libsystemd/sd-bus/test-bus-watch-bind.c
parent5cf91ea9c858fca03983c96932c886497953603e (diff)
downloadsystemd-15a3e96f9220c931507456764902ff05d7171318.tar.gz
tree-wide: port various users over to sockaddr_un_set_path()
CID 1396140 CID 1396141
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-watch-bind.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-watch-bind.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-watch-bind.c b/src/libsystemd/sd-bus/test-bus-watch-bind.c
index 1796feaa2f..40879b8537 100644
--- a/src/libsystemd/sd-bus/test-bus-watch-bind.c
+++ b/src/libsystemd/sd-bus/test-bus-watch-bind.c
@@ -40,10 +40,9 @@ static const sd_bus_vtable vtable[] = {
static void* thread_server(void *p) {
_cleanup_free_ char *suffixed = NULL, *suffixed2 = NULL, *d = NULL;
_cleanup_close_ int fd = -1;
- union sockaddr_union u = {
- .un.sun_family = AF_UNIX,
- };
+ union sockaddr_union u = {};
const char *path = p;
+ int salen;
log_debug("Initializing server");
@@ -66,12 +65,13 @@ static void* thread_server(void *p) {
assert_se(symlink(basename(suffixed), suffixed2) >= 0);
(void) usleep(100 * USEC_PER_MSEC);
- strncpy(u.un.sun_path, path, sizeof(u.un.sun_path));
+ salen = sockaddr_un_set_path(&u.un, path);
+ assert_se(salen >= 0);
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
assert_se(fd >= 0);
- assert_se(bind(fd, &u.sa, SOCKADDR_UN_LEN(u.un)) >= 0);
+ assert_se(bind(fd, &u.sa, salen) >= 0);
usleep(100 * USEC_PER_MSEC);
assert_se(listen(fd, SOMAXCONN) >= 0);