Blob Blame History Raw
From: Roger Shimizu <rogershimizu@gmail.com>
Date: Wed, 2 Nov 2016 00:32:22 +0900
Subject: resolv warnings so as to make "blhc" and "gcc" both happy

- blhc complained: lacking of CFLAGS/CPPFLAGS for C files in Makefile
- gcc complained implicit declaration of function 'time'
- gcc complained ignoring return value of 'read'
- adjust objects dependency and make parallel build working

Signed-off-by: Roger Shimizu <rogershimizu@gmail.com>
---
 Makefile.in          | 19 ++++++++++---------
 addrconf.c           | 11 ++++++++++-
 missing/arc4random.c |  3 ++-
 prefixconf.c         | 11 ++++++++++-
 4 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index de25f48..2c8d6f3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -36,7 +36,7 @@ localdbdir= @localdbdir@
 user= @user@
 group= @group@
 
-CFLAGS=	@CFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
+CFLAGS=	@CFLAGS@ @CPPFLAGS@ @DEFS@ -DSYSCONFDIR=\"${sysconfdir}\" \
 	-DLOCALDBDIR=\"${localdbdir}\"
 LDFLAGS=@LDFLAGS@
 LIBOBJS=@LIBOBJS@
@@ -73,7 +73,8 @@ dhcp6relay: $(RELAYOBJS) $(LIBOBJS)
 dhcp6ctl: $(CTLOBJS)
 	$(CC) $(LDFLAGS) -o $@ $(CTLOBJS) $(LIBOBJS) $(LIBS)
 
-cfparse.c y.tab.h: cfparse.y
+cfparse.c: y.tab.h
+y.tab.h: cfparse.y
 	@YACC@ -d cfparse.y
 	mv y.tab.c cfparse.c
 
@@ -82,21 +83,21 @@ cftoken.c: cftoken.l y.tab.h
 	mv lex.yy.c $@	
 
 getaddrinfo.o:	$(srcdir)/missing/getaddrinfo.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 getnameinfo.o:	$(srcdir)/missing/getnameinfo.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 strlcat.o:	$(srcdir)/missing/strlcat.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 strlcpy.o:	$(srcdir)/missing/strlcpy.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 arc4random.o:	$(srcdir)/missing/arc4random.c
 	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 getifaddrs.o:	$(srcdir)/missing/getifaddrs.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 daemon.o:	$(srcdir)/missing/daemon.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 warnx.o:	$(srcdir)/missing/warnx.c
-	$(CC) -c $(srcdir)/missing/$*.c
+	$(CC) $(CFLAGS) -c $(srcdir)/missing/$*.c
 
 $(srcdir)/ianaopts.h: gentab.pl bootp-dhcp-parameters
 	expand bootp-dhcp-parameters | perl gentab.pl > ianaopts.h
diff --git a/addrconf.c b/addrconf.c
index 47f1738..a8c52bc 100644
--- a/addrconf.c
+++ b/addrconf.c
@@ -29,11 +29,20 @@
  * SUCH DAMAGE.
  */
 #include <sys/types.h>
-#include <sys/time.h>
 #include <sys/socket.h>
 #include <sys/queue.h>
 #include <sys/ioctl.h>
 
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
 #include <net/if.h>
 #ifdef __FreeBSD__
 #include <net/if_var.h>
diff --git a/missing/arc4random.c b/missing/arc4random.c
index 8d1e050..7fe143b 100644
--- a/missing/arc4random.c
+++ b/missing/arc4random.c
@@ -59,9 +59,10 @@ u_int32_t
 arc4random()
 {
 	u_int32_t v;
+	ssize_t n;
 
 	if (fd < 0)
 		arc4random_init();
-	read(fd, &v, sizeof(v));
+	n = read(fd, &v, sizeof(v));
 	return v;
 }
diff --git a/prefixconf.c b/prefixconf.c
index 9450a3f..15b5417 100644
--- a/prefixconf.c
+++ b/prefixconf.c
@@ -29,11 +29,20 @@
  * SUCH DAMAGE.
  */
 #include <sys/types.h>
-#include <sys/time.h>
 #include <sys/socket.h>
 #include <sys/queue.h>
 #include <sys/ioctl.h>
 
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
 #include <net/if.h>
 #ifdef __FreeBSD__
 #include <net/if_var.h>