]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
util: Provide empty nvme_ipaddrs_eq for static builds
authorDaniel Wagner <dwagner@suse.de>
Mon, 26 Jun 2023 11:40:28 +0000 (13:40 +0200)
committerDaniel Wagner <wagi@monom.org>
Wed, 28 Jun 2023 10:56:31 +0000 (12:56 +0200)
Static builds can't use netdb functions, they are only available when
linking dynamically against glibc.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/util.c
test/meson.build

index 853bbbe3a2d7a6987eab13446ce0fd6e98400999..143cc318ab7a826a48701759af3f079cfeccc2a1 100644 (file)
@@ -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 */
index fdb9ecfb77b84d78ae4e5a710d76469ee3232776..49cd1acc74d09046aa30cc087f7d01322d0ba1bd 100644 (file)
@@ -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')