From: Daniel Wagner Date: Mon, 26 Jun 2023 11:40:28 +0000 (+0200) Subject: util: Provide empty nvme_ipaddrs_eq for static builds X-Git-Tag: v1.5~4 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5a1fdb0efedfe4e615d69c41b08b5128d4186350;p=users%2Fsagi%2Flibnvme.git util: Provide empty nvme_ipaddrs_eq for static builds Static builds can't use netdb functions, they are only available when linking dynamically against glibc. Signed-off-by: Daniel Wagner --- diff --git a/src/nvme/util.c b/src/nvme/util.c index 853bbbe3..143cc318 100644 --- a/src/nvme/util.c +++ b/src/nvme/util.c @@ -905,7 +905,9 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN]) return 0; } -bool nvme_ipaddrs_eq(const char *addr1, const char *addr2) { +#ifdef HAVE_NETDB +bool nvme_ipaddrs_eq(const char *addr1, const char *addr2) +{ bool result = false; struct addrinfo *info1 = NULL, hint1 = { .ai_flags=AI_NUMERICHOST, .ai_family=AF_UNSPEC }; struct addrinfo *info2 = NULL, hint2 = { .ai_flags=AI_NUMERICHOST, .ai_family=AF_UNSPEC }; @@ -961,4 +963,12 @@ ipaddrs_eq_fail: freeaddrinfo(info2); return result; } +#else /* HAVE_NETDB */ +bool nvme_ipaddrs_eq(const char *addr1, const char *addr2) +{ + nvme_msg(NULL, LOG_ERR, "no support for hostname ip address resolution; " \ + "recompile with libnss support.\n"); + return false; +} +#endif /* HAVE_NETDB */ diff --git a/test/meson.build b/test/meson.build index fdb9ecfb..49cd1acc 100644 --- a/test/meson.build +++ b/test/meson.build @@ -66,20 +66,22 @@ uuid = executable( test('uuid', uuid) -tree = executable( - 'tree', - ['tree.c'], - dependencies: libnvme_dep, - include_directories: [incdir, internal_incdir] -) +if conf.get('HAVE_NETDB') + tree = executable( + 'tree', + ['tree.c'], + dependencies: libnvme_dep, + include_directories: [incdir, internal_incdir] + ) -test('tree', tree) + test('tree', tree) -test_util = executable( - 'test-util', - ['test-util.c'], - include_directories: [incdir, internal_incdir] -) -test('Test util.c', test_util) + test_util = executable( + 'test-util', + ['test-util.c'], + include_directories: [incdir, internal_incdir] + ) + test('Test util.c', test_util) +endif subdir('nbft')