Skip to content

Commit 5ab8f14

Browse files
ThomasDevoogdtcosmo0920
authored andcommitted
network: fix strerror_r detection for musl
/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 janet-lang/janet@a5d6b22. Signed-off-by: Thomas Devoogdt <[email protected]>
1 parent 567ce06 commit 5ab8f14

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/flb_network.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,9 @@ static int net_connect_async(int fd,
638638
}
639639

640640
/* Connection is broken, not much to do here */
641-
#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
642-
(defined(_XOPEN_SOURCE) || _XOPEN_SOURCE - 0L >= 600L)) && \
643-
(!defined(_GNU_SOURCE))
641+
#ifdef __GLIBC__
642+
str = strerror_r(error, so_error_buf, sizeof(so_error_buf));
643+
#else
644644
ret = strerror_r(error, so_error_buf, sizeof(so_error_buf));
645645
if (ret == 0) {
646646
str = so_error_buf;
@@ -649,8 +649,6 @@ static int net_connect_async(int fd,
649649
flb_errno();
650650
return -1;
651651
}
652-
#else
653-
str = strerror_r(error, so_error_buf, sizeof(so_error_buf));
654652
#endif
655653
flb_error("[net] TCP connection failed: %s:%i (%s)",
656654
u->tcp_host, u->tcp_port, str);

0 commit comments

Comments
 (0)