068952c
From: Roger Shimizu <rogershimizu@gmail.com>
068952c
Date: Wed, 2 Nov 2016 00:32:22 +0900
068952c
Subject: resolv warnings so as to make "blhc" and "gcc" both happy
068952c
068952c
- blhc complained: lacking of CFLAGS/CPPFLAGS for C files in Makefile
068952c
- gcc complained implicit declaration of function 'time'
068952c
- gcc complained ignoring return value of 'read'
068952c
- adjust objects dependency and make parallel build working
068952c
068952c
Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
068952c
---
068952c
 Makefile.in          | 19 ++++++++++---------
068952c
 addrconf.c           | 11 ++++++++++-
068952c
 missing/arc4random.c |  3 ++-
068952c
 prefixconf.c         | 11 ++++++++++-
068952c
 4 files changed, 32 insertions(+), 12 deletions(-)
068952c
068952c
diff --git a/Makefile.in b/Makefile.in
068952c
index de25f48..2c8d6f3 100644
068952c
--- a/Makefile.in
068952c
+++ b/Makefile.in
068952c
@@ -36,7 +36,7 @@ localdbdir= @localdbdir@
068952c
 user= @user@
068952c
 group= @group@
068952c
 
068952c
-CFLAGS=	@CFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
068952c
+CFLAGS=	@CFLAGS@ @CPPFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
068952c
 	-DLOCALDBDIR=\"${localdbdir}\"
068952c
 LDFLAGS=@LDFLAGS@
068952c
 LIBOBJS=@LIBOBJS@
068952c
@@ -73,7 +73,8 @@ dhcp6relay: $(RELAYOBJS) $(LIBOBJS)
068952c
 dhcp6ctl: $(CTLOBJS)
068952c
 	$(CC) $(LDFLAGS) -o $@ $(CTLOBJS) $(LIBOBJS) $(LIBS)
068952c
 
068952c
-cfparse.c y.tab.h: cfparse.y
068952c
+cfparse.c: y.tab.h
068952c
+y.tab.h: cfparse.y
068952c
 	@YACC@ -d cfparse.y
068952c
 	mv y.tab.c cfparse.c
068952c
 
068952c
@@ -82,21 +83,21 @@ cftoken.c: cftoken.l y.tab.h
068952c
 	mv lex.yy.c $@	
068952c
 
068952c
 getaddrinfo.o:	$(srcdir)/missing/getaddrinfo.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 getnameinfo.o:	$(srcdir)/missing/getnameinfo.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 strlcat.o:	$(srcdir)/missing/strlcat.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 strlcpy.o:	$(srcdir)/missing/strlcpy.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 arc4random.o:	$(srcdir)/missing/arc4random.c
068952c
 	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 getifaddrs.o:	$(srcdir)/missing/getifaddrs.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 daemon.o:	$(srcdir)/missing/daemon.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 warnx.o:	$(srcdir)/missing/warnx.c
068952c
-	$(CC) -c $(srcdir)/missing/$*.c
068952c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
068952c
 
068952c
 $(srcdir)/ianaopts.h: gentab.pl bootp-dhcp-parameters
068952c
 	expand bootp-dhcp-parameters | perl gentab.pl > ianaopts.h
068952c
diff --git a/addrconf.c b/addrconf.c
068952c
index 47f1738..a8c52bc 100644
068952c
--- a/addrconf.c
068952c
+++ b/addrconf.c
068952c
@@ -29,11 +29,20 @@
068952c
  * SUCH DAMAGE.
068952c
  */
068952c
 #include <sys/types.h>
068952c
-#include <sys/time.h>
068952c
 #include <sys/socket.h>
068952c
 #include <sys/queue.h>
068952c
 #include <sys/ioctl.h>
068952c
 
068952c
+#if TIME_WITH_SYS_TIME
068952c
+# include <sys/time.h>
068952c
+# include <time.h>
068952c
+#else
068952c
+# if HAVE_SYS_TIME_H
068952c
+#  include <sys/time.h>
068952c
+# else
068952c
+#  include <time.h>
068952c
+# endif
068952c
+#endif
068952c
 #include <net/if.h>
068952c
 #ifdef __FreeBSD__
068952c
 #include <net/if_var.h>
068952c
diff --git a/missing/arc4random.c b/missing/arc4random.c
068952c
index 8d1e050..7fe143b 100644
068952c
--- a/missing/arc4random.c
068952c
+++ b/missing/arc4random.c
068952c
@@ -59,9 +59,10 @@ u_int32_t
068952c
 arc4random()
068952c
 {
068952c
 	u_int32_t v;
068952c
+	ssize_t n;
068952c
 
068952c
 	if (fd < 0)
068952c
 		arc4random_init();
068952c
-	read(fd, &v, sizeof(v));
068952c
+	n = read(fd, &v, sizeof(v));
068952c
 	return v;
068952c
 }
068952c
diff --git a/prefixconf.c b/prefixconf.c
068952c
index 9450a3f..15b5417 100644
068952c
--- a/prefixconf.c
068952c
+++ b/prefixconf.c
068952c
@@ -29,11 +29,20 @@
068952c
  * SUCH DAMAGE.
068952c
  */
068952c
 #include <sys/types.h>
068952c
-#include <sys/time.h>
068952c
 #include <sys/socket.h>
068952c
 #include <sys/queue.h>
068952c
 #include <sys/ioctl.h>
068952c
 
068952c
+#if TIME_WITH_SYS_TIME
068952c
+# include <sys/time.h>
068952c
+# include <time.h>
068952c
+#else
068952c
+# if HAVE_SYS_TIME_H
068952c
+#  include <sys/time.h>
068952c
+# else
068952c
+#  include <time.h>
068952c
+# endif
068952c
+#endif
068952c
 #include <net/if.h>
068952c
 #ifdef __FreeBSD__
068952c
 #include <net/if_var.h>