mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
Musl now seems to default to POSIX strerror_r, so we need to fix the function accordingly. Patch pulled from upstream 5ab8f149eeb2b4df596250a926eb6a39e373a834.
55 lines
2.2 KiB
Diff
55 lines
2.2 KiB
Diff
From 5ab8f149eeb2b4df596250a926eb6a39e373a834 Mon Sep 17 00:00:00 2001
|
||
From: Thomas Devoogdt <thomas@devoogdt.com>
|
||
Date: Sun, 31 Aug 2025 16:05:25 +0200
|
||
Subject: [PATCH] network: fix strerror_r detection for musl
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
/home/thomas/br-test-pkg/bootlin-armv7-musl/build/fluent-bit-4.0.8/src/flb_network.c: In function ‘net_connect_async’:
|
||
/home/thomas/br-test-pkg/bootlin-armv7-musl/build/fluent-bit-4.0.8/src/flb_network.c:653:17: error: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
|
||
653 | str = strerror_r(error, so_error_buf, sizeof(so_error_buf));
|
||
| ^
|
||
|
||
This fix should work perfectly for:
|
||
|
||
glibc systems: Uses str = strerror_r(...) (GNU version)
|
||
musl systems: Uses ret = strerror_r(...); if (ret == 0) str = so_error_buf; (POSIX version)
|
||
Other libc implementations: Defaults to POSIX behavior
|
||
|
||
Fix is similar to https://github.com/janet-lang/janet/commit/a5d6b2283834422a9fa9e79b5c7ad9b932b52568.
|
||
|
||
Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
|
||
---
|
||
src/flb_network.c | 8 +++-----
|
||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||
|
||
diff --git a/src/flb_network.c b/src/flb_network.c
|
||
index 4caad9ef1..5d6937ca7 100644
|
||
--- a/src/flb_network.c
|
||
+++ b/src/flb_network.c
|
||
@@ -638,9 +638,9 @@ static int net_connect_async(int fd,
|
||
}
|
||
|
||
/* Connection is broken, not much to do here */
|
||
-#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
|
||
- (defined(_XOPEN_SOURCE) || _XOPEN_SOURCE - 0L >= 600L)) && \
|
||
- (!defined(_GNU_SOURCE))
|
||
+#ifdef __GLIBC__
|
||
+ str = strerror_r(error, so_error_buf, sizeof(so_error_buf));
|
||
+#else
|
||
ret = strerror_r(error, so_error_buf, sizeof(so_error_buf));
|
||
if (ret == 0) {
|
||
str = so_error_buf;
|
||
@@ -649,8 +649,6 @@ static int net_connect_async(int fd,
|
||
flb_errno();
|
||
return -1;
|
||
}
|
||
-#else
|
||
- str = strerror_r(error, so_error_buf, sizeof(so_error_buf));
|
||
#endif
|
||
flb_error("[net] TCP connection failed: %s:%i (%s)",
|
||
u->tcp_host, u->tcp_port, str);
|
||
--
|
||
2.52.0
|
||
|