Skip to content

Commit 5a1fdb0

Browse files
dwsuseigaw
authored andcommitted
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 <[email protected]>
1 parent 1e1fc33 commit 5a1fdb0

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

src/nvme/util.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,9 @@ int nvme_uuid_random(unsigned char uuid[NVME_UUID_LEN])
905905
return 0;
906906
}
907907

908-
bool nvme_ipaddrs_eq(const char *addr1, const char *addr2) {
908+
#ifdef HAVE_NETDB
909+
bool nvme_ipaddrs_eq(const char *addr1, const char *addr2)
910+
{
909911
bool result = false;
910912
struct addrinfo *info1 = NULL, hint1 = { .ai_flags=AI_NUMERICHOST, .ai_family=AF_UNSPEC };
911913
struct addrinfo *info2 = NULL, hint2 = { .ai_flags=AI_NUMERICHOST, .ai_family=AF_UNSPEC };
@@ -961,4 +963,12 @@ bool nvme_ipaddrs_eq(const char *addr1, const char *addr2) {
961963
freeaddrinfo(info2);
962964
return result;
963965
}
966+
#else /* HAVE_NETDB */
967+
bool nvme_ipaddrs_eq(const char *addr1, const char *addr2)
968+
{
969+
nvme_msg(NULL, LOG_ERR, "no support for hostname ip address resolution; " \
970+
"recompile with libnss support.\n");
964971

972+
return false;
973+
}
974+
#endif /* HAVE_NETDB */

test/meson.build

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,22 @@ uuid = executable(
6666

6767
test('uuid', uuid)
6868

69-
tree = executable(
70-
'tree',
71-
['tree.c'],
72-
dependencies: libnvme_dep,
73-
include_directories: [incdir, internal_incdir]
74-
)
69+
if conf.get('HAVE_NETDB')
70+
tree = executable(
71+
'tree',
72+
['tree.c'],
73+
dependencies: libnvme_dep,
74+
include_directories: [incdir, internal_incdir]
75+
)
7576

76-
test('tree', tree)
77+
test('tree', tree)
7778

78-
test_util = executable(
79-
'test-util',
80-
['test-util.c'],
81-
include_directories: [incdir, internal_incdir]
82-
)
83-
test('Test util.c', test_util)
79+
test_util = executable(
80+
'test-util',
81+
['test-util.c'],
82+
include_directories: [incdir, internal_incdir]
83+
)
84+
test('Test util.c', test_util)
85+
endif
8486

8587
subdir('nbft')

0 commit comments

Comments
 (0)