From: Roy Marples Date: Mon, 21 Jan 2008 15:12:31 +0000 (+0000) Subject: We should use ssize_t here. X-Git-Tag: v3.2.3~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dffa4bc13ae9158e58b931afb91be7cb0d8dedf;p=thirdparty%2Fdhcpcd.git We should use ssize_t here. --- diff --git a/dhcp.c b/dhcp.c index 0c23a580..3fa93e84 100644 --- 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 a53d5759..ba2637cd 100644 --- 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); diff --git a/interface.c b/interface.c index 0225c00e..060c1416 100644 --- a/interface.c +++ b/interface.c @@ -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; diff --git a/socket.c b/socket.c index 27a3d533..8aa05539 100644 --- 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; diff --git a/socket.h b/socket.h index 7bd9e899..981225e2 100644 --- 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