]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
read(2) works on ssize_t so we should use this rather than size_t for our buffers...
authorRoy Marples <roy@marples.name>
Mon, 31 Mar 2008 10:23:59 +0000 (10:23 +0000)
committerRoy Marples <roy@marples.name>
Mon, 31 Mar 2008 10:23:59 +0000 (10:23 +0000)
arp.c
bpf.c
client.c
socket.c
socket.h

diff --git a/arp.c b/arp.c
index 3db1558094316b63e1c566a3353ac2b39bcd3f68..160acf1945f2d1e6ab157a7a82c843b50431220d 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -126,8 +126,8 @@ arp_claim(struct interface *iface, struct in_addr address)
                { -1, POLLIN, 0 },
                { -1, POLLIN, 0 }
        };
-       size_t bufpos = 0;
-       size_t buflen = iface->buffer_length;
+       ssize_t bufpos = 0;
+       ssize_t buflen = iface->buffer_length;
        int bytes;
        int s = 0;
        struct timeval stopat;
diff --git a/bpf.c b/bpf.c
index 5e978ecd1020d3b500a0a9aa7b5e9bad1f2b6dd6..0266b696bbfb9eae8c56fc9408477a7b4e1f33b5 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -115,7 +115,7 @@ open_socket(struct interface *iface, int protocol)
 
 ssize_t
 send_packet(const struct interface *iface, int type,
-           const unsigned char *data, size_t len)
+           const unsigned char *data, ssize_t len)
 {
        struct iovec iov[2];
        struct ether_header hw;
@@ -135,7 +135,7 @@ send_packet(const struct interface *iface, int type,
  * So we pass the buffer in the API so we can loop on >1 dhcp packet. */
 ssize_t
 get_packet(const struct interface *iface, unsigned char *data,
-          unsigned char *buffer, size_t *buffer_len, size_t *buffer_pos)
+          unsigned char *buffer, ssize_t *buffer_len, ssize_t *buffer_pos)
 {
        union
        {
@@ -153,7 +153,7 @@ get_packet(const struct interface *iface, unsigned char *data,
                struct udp_dhcp_packet *packet;
        } pay;
        struct timespec ts;
-       size_t len;
+       ssize_t len;
        unsigned char *payload;
        bool have_data;
 
@@ -204,7 +204,7 @@ get_packet(const struct interface *iface, unsigned char *data,
                /* Update the buffer_pos pointer */
                bpf.buffer += BPF_WORDALIGN(bpf.packet->bh_hdrlen +
                                            bpf.packet->bh_caplen);
-               if ((unsigned)(bpf.buffer - buffer) < *buffer_len)
+               if (bpf.buffer - buffer < *buffer_len)
                        *buffer_pos = bpf.buffer - buffer;
                else
                        *buffer_pos = 0;
index 23d7cc0f3d6ae51eb43f983c190db5bbc69b652b..68afa71209af32e9e0dd959b776fd4b6a5299aef 100644 (file)
--- a/client.c
+++ b/client.c
@@ -123,8 +123,8 @@ struct if_state {
        bool daemonised;
        bool persistent;
        unsigned char *buffer;
-       size_t buffer_len;
-       size_t buffer_pos;
+       ssize_t buffer_len;
+       ssize_t buffer_pos;
 };
 
 static pid_t
index 3bd765ac556991ae23b68e2bee6664e0b62cc076..b9862a65232cc03c721dfb290886316eb684e32f 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -182,7 +182,7 @@ eexit:
 
 ssize_t
 send_packet(const struct interface *iface, int type,
-           const unsigned char *data, size_t len)
+           const unsigned char *data, ssize_t len)
 {
        union sockunion {
                struct sockaddr sa;
@@ -214,7 +214,7 @@ send_packet(const struct interface *iface, int type,
  * We only have the buffer listed to keep the same API. */
 ssize_t
 get_packet(const struct interface *iface, unsigned char *data,
-          unsigned char *buffer, size_t *buffer_len, size_t *buffer_pos)
+          unsigned char *buffer, ssize_t *buffer_len, ssize_t *buffer_pos)
 {
        ssize_t bytes;
        union
index 67366da8584881ed57f1645e715d20e280ac270e..90922f8c88ddca7cca5e71f4dc1907053fcbfe27 100644 (file)
--- a/socket.h
+++ b/socket.h
@@ -39,7 +39,7 @@ void setup_packet_filters(void);
 
 int open_socket(struct interface *, int);
 ssize_t send_packet(const struct interface *, int,
-                   const unsigned char *, size_t);
+                   const unsigned char *, ssize_t);
 ssize_t get_packet(const struct interface *, unsigned char *,
-                  unsigned char *, size_t *, size_t *);
+                  unsigned char *, ssize_t *, ssize_t *);
 #endif