From 9eac2a8963415e6a74c2fc13a3c8d05cd0f81d4d Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 28 Feb 2017 21:48:29 -0800 Subject: dhcpv6-ia: Check lockf return value Check the lockf return value to fix the following warning/error: /home/fainelli/dev/openwrt/trunk/build_dir/target-mipsel-linux-gnu_glibc/odhcpd-2017-02-21-1b630f8b/src/dhcpv6-ia.c: In function 'dhcpv6_write_statefile': /home/fainelli/dev/openwrt/trunk/build_dir/target-mipsel-linux-gnu_glibc/odhcpd-2017-02-21-1b630f8b/src/dhcpv6-ia.c:246:8: error: ignoring return value of 'lockf', declared with attribute warn_unused_result [-Werror=unused-result] lockf(fd, F_LOCK, 0); ^ cc1: all warnings being treated as errors Signed-off-by: Florian Fainelli --- src/dhcpv6-ia.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/dhcpv6-ia.c') diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index 888634f..fb50448 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -242,8 +242,12 @@ void dhcpv6_write_statefile(void) int fd = open(config.dhcp_statefile, O_CREAT | O_WRONLY | O_CLOEXEC, 0644); if (fd < 0) return; - - lockf(fd, F_LOCK, 0); + int ret; + ret = lockf(fd, F_LOCK, 0); + if (ret < 0) { + close(fd); + return; + } if (ftruncate(fd, 0) < 0) {} FILE *fp = fdopen(fd, "w"); -- cgit v1.2.3