Skip to content

Commit 0571fcc

Browse files
committed
network: Fix build under Clang
If we have #define HAVE_DNS_SD 0, Clang 9 (and probably other versions) will correctly detect that "if (HAVE_DNS_SD && ret)" is dead code, but will fail to detect that "if (ret && HAVE_DNS_SD)" is dead code. If the dead code calls symbols not provided at link time, then linking will then fail. Fix this by swapping the two expressions in the "if" block. Stupid, right? Signed-off-by: Paul Cercueil <[email protected]> Reported-by: Adrian Suciu <[email protected]>
1 parent ee4add3 commit 0571fcc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ struct iio_context * network_create_context(const char *host)
11031103
* which might be not the case for some minimalist distros. In this case,
11041104
* as a last resort, let's try to resolve the host with avahi...
11051105
*/
1106-
if (ret && HAVE_DNS_SD) {
1106+
if (HAVE_DNS_SD && ret) {
11071107
char addr_str[DNS_SD_ADDRESS_STR_MAX];
11081108

11091109
IIO_DEBUG("'getaddrinfo()' failed: %s. Trying dnssd as a last resort...\n",

0 commit comments

Comments
 (0)