]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Compiles on FreeBSD again
authorRoy Marples <roy@marples.name>
Fri, 15 Dec 2006 00:00:18 +0000 (00:00 +0000)
committerRoy Marples <roy@marples.name>
Fri, 15 Dec 2006 00:00:18 +0000 (00:00 +0000)
ChangeLog
Makefile
socket.c

index cca60bc38034579eab35a62179320a49280f35da..6b49b0f67c784712cca60d0ffd386b41a88ab0cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Add new CFLAGS to ensure that the code quality is good.
+Use const more in public functions.
+
 dhcpcd-3.0.6
 Don't set the broadcast flag anymore as all BPF and Linux sockets should be
 able to unicast correctly.
index a4b80ea83e1c0d52975ea26f19c08ba0b66c2aea..80b5299c6f4135a6f073f0462f09f8f0f98e7cd0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,9 @@
 VERSION = 3.0.7_pre1
 
 INSTALL ?= install
+
+# Loads of nice flags to ensure our code is good
+# And yes, we require C99 style code which means gcc-3 as a minimum
 CFLAGS = -O2 -pedantic -std=gnu99 \
     -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
     -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
index a24f256086fcf9c7ffdbb8d941d0397e14ec3fad..8987f7aa28db1b305cc673b5b7ba746e066ac7d6 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -294,7 +294,8 @@ int open_socket (interface_t *iface, bool arp)
   return fd;
 }
 
-int send_packet (interface_t *iface, int type, unsigned char *data, int len)
+int send_packet (const interface_t *iface, int type,
+                const unsigned char *data, int len)
 {
   /* We only support ethernet atm */
   struct ether_header hw;
@@ -307,7 +308,7 @@ int send_packet (interface_t *iface, int type, unsigned char *data, int len)
 
   iov[0].iov_base = &hw;
   iov[0].iov_len = sizeof (struct ether_header);
-  iov[1].iov_base = data;
+  iov[1].iov_base = (unsigned char *) data;
   iov[1].iov_len = len;
 
   if ((retval = writev(iface->fd, iov, 2)) == -1)
@@ -318,7 +319,7 @@ int send_packet (interface_t *iface, int type, unsigned char *data, int len)
 
 /* BPF requires that we read the entire buffer.
    So we pass the buffer in the API so we can loop on >1 dhcp packet. */
-int get_packet (interface_t *iface, unsigned char *data,
+int get_packet (const interface_t *iface, unsigned char *data,
                unsigned char *buffer, int *buffer_len, int *buffer_pos)
 {
   unsigned char *buf = buffer;
@@ -349,8 +350,8 @@ int get_packet (interface_t *iface, unsigned char *data,
     {
       /* Ensure that the entire packet is in our buffer */
       if (*buffer_pos + packet->bh_hdrlen + packet->bh_caplen
-          > (unsigned) *buffer_len)
-        break;
+         > (unsigned) *buffer_len)
+       break;
 
       hw = (struct ether_header *) ((char *) packet + packet->bh_hdrlen);
       hdr = (unsigned char *) ((char *) hw + sizeof (struct ether_header));
@@ -430,7 +431,7 @@ int open_socket (interface_t *iface, bool arp)
       close (fd);
       return -1;
     }
-  
+
   if (iface->fd > -1)
     close (iface->fd);
   iface->fd = fd;
@@ -467,7 +468,7 @@ int send_packet (const interface_t *iface, const int type,
 /* Linux has no need for the buffer as we can read as much as we want.
    We only have the buffer listed to keep the same API. */
 int get_packet (const interface_t *iface, unsigned char *data,
-                  unsigned char *buffer, int *buffer_len, int *buffer_pos)
+               unsigned char *buffer, int *buffer_len, int *buffer_pos)
 {
   long bytes;