From a9752d9982bcf645f5d91749ff4e6f1be5466db4 Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@ariadne.space>
Date: Wed, 4 Sep 2024 15:14:52 -0700
Subject: [PATCH] community/libteam: fix build with GCC 14

---
 community/libteam/APKBUILD    |  2 ++
 community/libteam/gcc14.patch | 36 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 community/libteam/gcc14.patch

diff --git a/community/libteam/APKBUILD b/community/libteam/APKBUILD
index e99b3b3a81be..41e308578891 100644
--- a/community/libteam/APKBUILD
+++ b/community/libteam/APKBUILD
@@ -17,6 +17,7 @@ source="$pkgname-$pkgver.tar.gz::https://github.com/jpirko/libteam/archive/v$pkg
 	fix-redefinition-struct-ethhdr.patch
 	swig4.1.patch
 	implicit-function-decl.patch
+	gcc14.patch
 	"
 
 prepare() {
@@ -59,4 +60,5 @@ sha512sums="
 db2f374018a8b60c099e5b41abf5a9d20912bddc0436788b246815459c97498fb47d237376f87a623438f2f48d486d91d65fe5b49aeeabc83cbd41bdb66d7bfc  fix-redefinition-struct-ethhdr.patch
 50c39a8264e7adb6313b2109ef68d18cb3f46c67e88d6cd3f393c26738fe7d4e34fd7b9dba0a4e0a9d6a2da793d847741f5fe1069f82319adfb4f3d884ffece8  swig4.1.patch
 35ff644b50feae4e23d5527c6cf173c0450b02c0e737c33a4a4d0041c644ff8cf7f33e92de2491e5f4de6d96b5342ba3b04228b7101d1eb551b961b37a62f690  implicit-function-decl.patch
+f8886301d4861530c6c9a81f069e0e88a7c0be7d89f67b0d4ab872b5ea88d01cd7482401b86e38797b4b33768b536255a746158c0bd669a0af7b245aee5e820d  gcc14.patch
 "
diff --git a/community/libteam/gcc14.patch b/community/libteam/gcc14.patch
new file mode 100644
index 000000000000..8e6c45b85ca8
--- /dev/null
+++ b/community/libteam/gcc14.patch
@@ -0,0 +1,36 @@
+From 4eb54a811bef43da2be9cc84009567e5d6ca9741 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 11 May 2024 23:15:59 -0700
+Subject: [PATCH] teamd: Pass correct parameter type to accept API
+
+accept() expects sockaddr as second parameter
+
+int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
+
+Fixes build with gcc-16 on musl systems
+| ../../git/teamd/teamd_usock.c: In function 'callback_usock':
+| ../../git/teamd/teamd_usock.c:280:40: error: passing argument 2 of 'accept' from incompatible pointer type [-Wincompatible-pointer-types]
+|   280 |         sock = accept(ctx->usock.sock, &addr, &alen);
+|       |                                        ^~~~~
+|       |                                        |
+|       |                                        struct sockaddr_un *
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Signed-off-by: Jiri Pirko <jiri@nvidia.com>
+---
+ teamd/teamd_usock.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/teamd/teamd_usock.c b/teamd/teamd_usock.c
+index 1adfdf8..5895124 100644
+--- a/teamd/teamd_usock.c
++++ b/teamd/teamd_usock.c
+@@ -277,7 +277,7 @@ static int callback_usock(struct teamd_context *ctx, int events, void *priv)
+ 	int err;
+ 
+ 	alen = sizeof(addr);
+-	sock = accept(ctx->usock.sock, &addr, &alen);
++	sock = accept(ctx->usock.sock, (struct sockaddr *)&addr, &alen);
+ 	if (sock == -1) {
+ 		teamd_log_err("usock: Failed to accept connection.");
+ 		return -errno;
-- 
GitLab