From e014b41377e628af7d6460c77a65e27ad56ad754 Mon Sep 17 00:00:00 2001 From: Adam Green Date: Tue, 13 Aug 2013 20:50:02 -0700 Subject: [PATCH] Silence signed/unsigned comparison warnings in GCC The dn variable in lpc_low_level_output() was originally defined as a u32_t but it is later compared to the s32_t return value from lpc_tx_ready(). Since it is intialized to pbuf_clean() which returns a u8_t, a s32_t type can safely hold the initial value and remains consistent with the signed lpc_tx_ready() comparison. I also modifed writtenLen in TCPSocketConnection::send_all() and readLen in TCPSocketConnection::recieve_all() to be of type int instead of size_t. This is more consistent with their usage within these methods (they accumulate int ret values and are compared to the int length value) and their use as a signed integer return values. --- libraries/net/eth/lwip-eth/arch/lpc17_emac.c | 6 +++--- libraries/net/lwip/Socket/TCPSocketConnection.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/net/eth/lwip-eth/arch/lpc17_emac.c b/libraries/net/eth/lwip-eth/arch/lpc17_emac.c index 0d06464ab7..06772f48f1 100644 --- a/libraries/net/eth/lwip-eth/arch/lpc17_emac.c +++ b/libraries/net/eth/lwip-eth/arch/lpc17_emac.c @@ -618,14 +618,14 @@ static err_t lpc_low_level_output(struct netif *netif, struct pbuf *p) struct lpc_enetdata *lpc_enetif = netif->state; struct pbuf *q; u8_t *dst; - u32_t idx; + u32_t idx, notdmasafe = 0; struct pbuf *np; - u32_t dn, notdmasafe = 0; + s32_t dn; /* Zero-copy TX buffers may be fragmented across mutliple payload chains. Determine the number of descriptors needed for the transfer. The pbuf chaining can be a mess! */ - dn = (u32_t) pbuf_clen(p); + dn = (s32_t) pbuf_clen(p); /* Test to make sure packet addresses are DMA safe. A DMA safe address is once that uses external memory or periphheral RAM. diff --git a/libraries/net/lwip/Socket/TCPSocketConnection.cpp b/libraries/net/lwip/Socket/TCPSocketConnection.cpp index d84dc9c6b3..b853304099 100644 --- a/libraries/net/lwip/Socket/TCPSocketConnection.cpp +++ b/libraries/net/lwip/Socket/TCPSocketConnection.cpp @@ -66,7 +66,7 @@ int TCPSocketConnection::send_all(char* data, int length) { if ((_sock_fd < 0) || !_is_connected) return -1; - size_t writtenLen = 0; + int writtenLen = 0; TimeInterval timeout(_timeout); while (writtenLen < length) { if (!_blocking) { @@ -110,7 +110,7 @@ int TCPSocketConnection::receive_all(char* data, int length) { if ((_sock_fd < 0) || !_is_connected) return -1; - size_t readLen = 0; + int readLen = 0; TimeInterval timeout(_timeout); while (readLen < length) { if (!_blocking) {