]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We should use ssize_t here.
authorRoy Marples <roy@marples.name>
Mon, 21 Jan 2008 15:12:31 +0000 (15:12 +0000)
committerRoy Marples <roy@marples.name>
Mon, 21 Jan 2008 15:12:31 +0000 (15:12 +0000)
dhcp.c
dhcp.h
interface.c
socket.c
socket.h

diff --git a/dhcp.c b/dhcp.c
index 0c23a580b60ae6561df9e38d186dde7a4a64ac23..3fa93e841e326fa52e5d3ded978f6a246a1c8598 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -78,9 +78,9 @@ static const char *dhcp_message (int type)
        return (NULL);
 }
 
-size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
-                    unsigned long xid, char type,
-                    const options_t *options)
+ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
+                     unsigned long xid, char type,
+                     const options_t *options)
 {
        struct udp_dhcp_packet *packet;
        dhcpmessage_t *message;
@@ -94,7 +94,7 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
        uint32_t ul;
        uint16_t sz;
        unsigned int message_length;
-       size_t retval;
+       ssize_t retval;
 
        if (!iface || !options || !dhcp)
                return -1;
@@ -641,6 +641,7 @@ static route_t *decode_routers (const unsigned char *data, int length)
 
        return (head);
 }
+
 int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message)
 {
        const unsigned char *p = message->options;
diff --git a/dhcp.h b/dhcp.h
index a53d575972203d5597dd1be483ea213737f358e4..ba2637cd493eaf0c956aedb6ad2c9580438540b8 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -208,9 +208,9 @@ struct udp_dhcp_packet
        dhcpmessage_t dhcp;
 };
 
-size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
-                    unsigned long xid, char type,
-                    const options_t *options);
+ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
+                     unsigned long xid, char type,
+                     const options_t *options);
 void free_dhcp (dhcp_t *dhcp);
 int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message);
 
index 0225c00e03935944dfdf0215ef2a70dedf581d58..060c1416f8701ffaf6f68dfda72434f16737a9cc 100644 (file)
@@ -671,7 +671,7 @@ static int send_netlink(struct nlmsghdr *hdr)
        struct msghdr msg;
        static unsigned int seq;
        char *buffer;
-       int bytes;
+       ssize_t bytes;
        union
        {
                char *buffer;
index 27a3d533daca4ed866f751ff6cfe8e815a2e3fda..8aa05539a105d86d5daa39c8b2846688499cd06d 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -308,10 +308,10 @@ int open_socket (interface_t *iface, bool arp)
        return fd;
 }
 
-int send_packet (const interface_t *iface, int type,
-                const unsigned char *data, int len)
+ssize_t send_packet (const interface_t *iface, int type,
+                    const unsigned char *data, int len)
 {
-       int retval = -1;
+       ssize_t retval = -1;
        struct iovec iov[2];
 
        if (iface->family == ARPHRD_ETHER) {
@@ -337,8 +337,8 @@ int send_packet (const interface_t *iface, int type,
 
 /* 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 (const interface_t *iface, unsigned char *data,
-               unsigned char *buffer, int *buffer_len, int *buffer_pos)
+ssize_t get_packet (const interface_t *iface, unsigned char *data,
+                   unsigned char *buffer, int *buffer_len, int *buffer_pos)
 {
        union
        {
@@ -364,7 +364,7 @@ int get_packet (const interface_t *iface, unsigned char *data,
                bpf.buffer += *buffer_pos;
 
        while (bpf.packet) {
-               int len = -1;
+               ssize_t len = -1;
                union
                {
                        unsigned char *buffer;
@@ -478,15 +478,15 @@ int open_socket (interface_t *iface, bool arp)
        return fd;
 }
 
-int send_packet (const interface_t *iface, const int type,
-                const unsigned char *data, const int len)
+ssize_t send_packet (const interface_t *iface, const int type,
+                    const unsigned char *data, const int len)
 {
        union sockunion {
                struct sockaddr sa;
                struct sockaddr_ll sll;
                struct sockaddr_storage ss;
        } su;
-       int retval;
+       ssize_t retval;
 
        if (! iface)
                return -1;
@@ -511,10 +511,10 @@ 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)
+ssize_t get_packet (const interface_t *iface, unsigned char *data,
+                   unsigned char *buffer, int *buffer_len, int *buffer_pos)
 {
-       long bytes;
+       ssize_t bytes;
        union
        {
                unsigned char *buffer;
index 7bd9e8997bb54dc917b5c0ae066625794417cb40..981225e2d7a1c447d7aa942dafc6004a84179161 100644 (file)
--- a/socket.h
+++ b/socket.h
@@ -38,8 +38,8 @@ void make_dhcp_packet(struct udp_dhcp_packet *packet,
                      struct in_addr source, struct in_addr dest);
 
 int open_socket (interface_t *iface, bool arp);
-int send_packet (const interface_t *iface, int type,
-                const unsigned char *data, int len);
-int get_packet (const interface_t *iface, unsigned char *data,
-               unsigned char *buffer, int *buffer_len, int *buffer_pos);
+ssize_t send_packet (const interface_t *iface, int type,
+                    const unsigned char *data, int len);
+ssize_t get_packet (const interface_t *iface, unsigned char *data,
+                   unsigned char *buffer, int *buffer_len, int *buffer_pos);
 #endif