dhcp: Fix compiler error
|Reported by:||thomas||Owned by:||thomas|
(Reported by Clayton J. on blfs-dev)
Instructions in book leads to errors like
discover.c:646:4: error: 'strncpy' output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation] strncpy(tmp->name, info.name, sizeof(tmp->name) - 1);
This is caused by a strange handling of set/unset CFLAGS. Doing an
makes it compile. Most likely it has been missed because we might had CFLAGS exported while testing. With this export of CFLAGS, our -D's are recognized but but
-fno-strict-aliasing gets not set but it would be if CFLAGS are not spezified.
Remove the -Werror flag by doing a
sed -e "/STD_CWARNINGS=/ s/-Werror//" -i configure
This would make it compile too but the CFLAGS we set (without the export) will not be used. See summary of configure script.
I'd propose to solve it like this:
export CFLAGS="$CFLAGS -Wall -fno-strict-aliasing \ -D_PATH_DHCLIENT_SCRIPT='\"/sbin/dhclient-script\"' \ -D_PATH_DHCPD_CONF='\"/etc/dhcp/dhcpd.conf\"' \ -D_PATH_DHCLIENT_CONF='\"/etc/dhcp/dhclient.conf\"'" ./configure --prefix=/usr \ --sysconfdir=/etc/dhcp \ --localstatedir=/var \ --with-srv-lease-file=/var/lib/dhcpd/dhcpd.leases \ --with-srv6-lease-file=/var/lib/dhcpd/dhcpd6.leases \ --with-cli-lease-file=/var/lib/dhclient/dhclient.leases \ --with-cli6-lease-file=/var/lib/dhclient/dhclient6.leases
The summary of configure than looks like (note the CFLAGS line):
ISC DHCP source configure results: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Package: Name: DHCP Version: 4.4.1 C Compiler: gcc Flags: DEFS: -DHAVE_CONFIG_H CFLAGS: -Wall -fno-strict-aliasing -D_PATH_DHCLIENT_SCRIPT='"/sbin/dhclient-script"' -D_PATH_DHCPD_CONF='"/etc/dhcp/dhcpd.conf"' -D_PATH_DHCLIENT_CONF='"/etc/dhcp/dhclient.conf"' -I$(top_srcdir)/includes -I/home/lfs/dhcp-4.4.1/bind/include DHCP versions: DHCPv4 and DHCPv6 Features: debug: no failover: yes execute: yes binary-leases: no dhcpv6: yes delayed-ack: yes dhcpv4o6: no relay-port: no Developer: ATF unittests : no Now you can type make to build ISC DHCP
Please add comments!