diff mbox series

[v2,06/12] e1000: Compile with -Wextra

Message ID 20210209014457.108301-7-aik@ozlabs.ru
State Accepted
Headers show
Series Compile with -Wextra | expand

Commit Message

Alexey Kardashevskiy Feb. 9, 2021, 1:44 a.m. UTC
-Wextra enables a bunch of rather useful checks which this fixes.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 lib/libe1k/e1k.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lib/libe1k/e1k.c b/lib/libe1k/e1k.c
index 4dd7d2eb97c2..3bbc75fba199 100644
--- a/lib/libe1k/e1k.c
+++ b/lib/libe1k/e1k.c
@@ -163,7 +163,7 @@  static const e1k_dev_t e1k_dev[] = {
 	{ 0x1016, E1K_82540, "82540EP Mobile" },
 	{ 0x1017, E1K_82540, "82540EP Desktop" },
 	{ 0x100E, E1K_82540, "82540EM Desktop" },
-	{ 0     , 0 }
+	{ 0 }
 };
 
 /*
@@ -182,8 +182,8 @@  check_driver(uint16_t vendor_id, uint16_t device_id);
 
 static int e1k_init(net_driver_t *driver);
 static int e1k_term(void);
-static int e1k_xmit(char *f_buffer_pc, int f_len_i);
-static int e1k_receive(char *f_buffer_pc, int f_len_i);
+static int e1k_xmit(char *f_buffer_pc, unsigned f_len_i);
+static int e1k_receive(char *f_buffer_pc, unsigned f_len_i);
 
 /**
  * Translate virtual to "physical" address, ie. an address
@@ -549,11 +549,11 @@  e1k_mac_init(uint8_t *f_mac_pu08)
  * e1k_receive
  */
 static int
-e1k_receive(char *f_buffer_pc, int f_len_i)
+e1k_receive(char *f_buffer_pc, unsigned f_len_i)
 {
 	uint32_t	l_rdh_u32 = e1k_rd32(RDH);	// this includes needed dummy read
 	e1k_rx_desc_st	*rx;
-	int		l_ret_i;
+	unsigned	l_ret_i;
 
 	#ifdef E1K_DEBUG
 	#ifdef E1K_SHOW_RCV_DATA
@@ -589,11 +589,11 @@  e1k_receive(char *f_buffer_pc, int f_len_i)
 	 * copy the data
 	 */
 	memcpy((uint8_t *) f_buffer_pc, dma2virt(bswap_64(rx->m_buffer_u64)),
-		(size_t) l_ret_i);
+		(size_t) MIN(l_ret_i, f_len_i));
 
 	#ifdef E1K_DEBUG
 	#if defined(E1K_SHOW_RCV) || defined(E1K_SHOW_RCV_DATA)
-	printf("e1k: %d bytes received\n", l_ret_i);
+	printf("e1k: %d bytes received (max %d)\n", l_ret_i, f_len_i);
 	#endif
 
 	#ifdef E1K_SHOW_RCV_DATA
@@ -631,7 +631,7 @@  e1k_receive(char *f_buffer_pc, int f_len_i)
 }
 
 static int
-e1k_xmit(char *f_buffer_pc, int f_len_i)
+e1k_xmit(char *f_buffer_pc, unsigned f_len_i)
 {
 	uint32_t	l_tdh_u32 = e1k_rd32(TDH);
 	uint32_t	l_tdt_u32 = e1k_rd32(TDT);