Skip to content

Commit 663d55e

Browse files
committed
Change DHCP inline function definition to static inline
Compiling Pi-hole FTL w/o optimization (release type "DEBUG") results in the following error during linking: ''' x86_64-buildroot-linux-uclibc/bin/ld: tools/CMakeFiles/tools.dir/dhcp-discover.c.o: in function `create_dhcp_socket': /home/data/buildroot.experimental/build/pihole-ftl-6.6/src/tools/dhcp-discover.c:88:(.text+0xac): undefined reference to `start_lock' x86_64-buildroot-linux-uclibc/bin/ld: /home/data/buildroot.experimental/build/pihole-ftl-6.6/src/tools/dhcp-discover.c:90:(.text+0xe9): undefined reference to `end_lock' [...] x86_64-buildroot-linux-uclibc/bin/ld: tools/CMakeFiles/tools.dir/dhcpv6-discover.c.o: in function `recv_adv': /home/data/buildroot.experimental/build/pihole-ftl-6.6/src/tools/dhcpv6-discover.c:706:(.text+0x137f): undefined reference to `start_lock' x86_64-buildroot-linux-uclibc/bin/ld: /home/data/buildroot.experimental/build/pihole-ftl-6.6/src/tools/dhcpv6-discover.c:709:(.text+0x13b1): undefined reference to `end_lock' [...] ''' When generating code without optimization, gcc ignores the inline directive. Code for this function is generated once, but not marked as global (because the extern keyword is missing), which results in the observed linker error for all other compilation units. Change the function definition to static inline, which will force the compiler to include a static copy of the function in every compilation unit, if the function is not inlined. Signed-off-by: Andreas Ziegler <[email protected]>
1 parent fb6b19f commit 663d55e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/tools/dhcp-discover.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ int get_hardware_address(const int sock, const char *iname, unsigned char *mac);
2020
// Global lock used by all threads
2121
extern pthread_mutex_t dhcp_lock;
2222

23-
inline void start_lock(void)
23+
static inline void start_lock(void)
2424
{
2525
pthread_mutex_lock(&dhcp_lock);
2626
}
2727

28-
inline void end_lock(void)
28+
static inline void end_lock(void)
2929
{
3030
pthread_mutex_unlock(&dhcp_lock);
3131
}

0 commit comments

Comments
 (0)