[OE-core][kirkstone 07/31] systemd: Fix build regression with latest update

Steve Sakoman
2022-05-17T18:24:57Z

From: Khem Raj <raj.khem@gmail.com>

This happens when ptest is enabled with clang compiler

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit a1f51bae8e4717da2375b9a476c368554a795487)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
...e-Use-sockaddr-pointer-type-for-bind.patch | 46 +++++++++++++++++++
meta/recipes-core/systemd/systemd_250.5.bb | 1 +
2 files changed, 47 insertions(+)
create mode 100644 meta/recipes-core/systemd/systemd/0001-resolve-Use-sockaddr-pointer-type-for-bind.patch

diff --git a/meta/recipes-core/systemd/systemd/0001-resolve-Use-sockaddr-pointer-type-for-bind.patch b/meta/recipes-core/systemd/systemd/0001-resolve-Use-sockaddr-pointer-type-for-bind.patch
new file mode 100644
index 0000000000..8567283537
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-resolve-Use-sockaddr-pointer-type-for-bind.patch
@@ -0,0 +1,46 @@
+From ad1428f29196bcc88ae382ee67ff705928e2be24 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 5 May 2022 20:25:37 -0700
+Subject: [PATCH] resolve: Use sockaddr pointer type for bind()
+
+bind() expects sockaddr* but SERVER_ADDRESS is sockaddr_in type struct
+
+Fixes errors with clang e.g.
+
+../git/src/resolve/test-resolved-stream.c:112:32: error: incompatible pointer types passing 'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' [-Werror,-Wincompatible-pointer-types]
+ assert_se(bind(bindfd, &SERVER_ADDRESS, sizeof(SERVER_ADDRESS)) >= 0);
+ ^~~~~~~~~~~~~~~
+../git/src/resolve/test-resolved-stream.c:251:39: error: incompatible pointer types passing 'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' [-Werror,-Wincompatible-pointer-types]
+ r = connect(clientfd, &SERVER_ADDRESS, sizeof(SERVER_ADDRESS));
+
+Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/23281]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/resolve/test-resolved-stream.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/resolve/test-resolved-stream.c b/src/resolve/test-resolved-stream.c
+index f12c729e50..504b532002 100644
+--- a/src/resolve/test-resolved-stream.c
++++ b/src/resolve/test-resolved-stream.c
+@@ -109,7 +109,7 @@ static void *tcp_dns_server(void *p) {
+
+ assert_se((bindfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) >= 0);
+ assert_se(setsockopt(bindfd, SOL_SOCKET, SO_REUSEADDR, &(int){1}, sizeof(int)) >= 0);
+- assert_se(bind(bindfd, &SERVER_ADDRESS, sizeof(SERVER_ADDRESS)) >= 0);
++ assert_se(bind(bindfd, (struct sockaddr*)&SERVER_ADDRESS, sizeof(SERVER_ADDRESS)) >= 0);
+ assert_se(listen(bindfd, 1) >= 0);
+ assert_se((acceptfd = accept(bindfd, NULL, NULL)) >= 0);
+ server_handle(acceptfd);
+@@ -248,7 +248,7 @@ static void test_dns_stream(bool tls) {
+ assert_se((clientfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) >= 0);
+
+ for (int i = 0; i < 100; i++) {
+- r = connect(clientfd, &SERVER_ADDRESS, sizeof(SERVER_ADDRESS));
++ r = connect(clientfd, (struct sockaddr*)&SERVER_ADDRESS, sizeof(SERVER_ADDRESS));
+ if (r >= 0)
+ break;
+ usleep(EVENT_TIMEOUT_USEC / 100);
+--
+2.36.0
+
diff --git a/meta/recipes-core/systemd/systemd_250.5.bb b/meta/recipes-core/systemd/systemd_250.5.bb
index 2cf3b7ca88..e5a2f65202 100644
--- a/meta/recipes-core/systemd/systemd_250.5.bb
+++ b/meta/recipes-core/systemd/systemd_250.5.bb
@@ -25,6 +25,7 @@ SRC_URI += "file://touchscreen.rules \
file://0003-implment-systemd-sysv-install-for-OE.patch \
file://0001-systemd.pc.in-use-ROOTPREFIX-without-suffixed-slash.patch \
file://0001-test-parse-argument-Include-signal.h.patch \
+ file://0001-resolve-Use-sockaddr-pointer-type-for-bind.patch \
"

# patches needed by musl
--
2.25.1