From: David van Moolenbroek Date: Fri, 3 Aug 2012 16:10:24 +0000 (+0000) Subject: e1000: resolve Coverity warnings X-Git-Tag: v3.2.1~408 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=4f877afeb61ccf08f4735e1e9185fbe5caa644f5;p=minix.git e1000: resolve Coverity warnings --- diff --git a/drivers/e1000/e1000.c b/drivers/e1000/e1000.c index e0fe93db9..47f21f026 100644 --- a/drivers/e1000/e1000.c +++ b/drivers/e1000/e1000.c @@ -212,8 +212,8 @@ static void e1000_init_pci() /* Try to detect e1000's. */ e = &e1000_state; - strcpy(e->name, "e1000#0"); - e->name[6] += e1000_instance; + strlcpy(e->name, "e1000#0", sizeof(e->name)); + e->name[6] += e1000_instance; e1000_probe(e, e1000_instance); } @@ -477,8 +477,8 @@ e1000_t *e; static void e1000_init_buf(e) e1000_t *e; { - phys_bytes rx_desc_p, rx_buff_p; - phys_bytes tx_desc_p, tx_buff_p; + phys_bytes rx_buff_p; + phys_bytes tx_buff_p; int i; /* Number of descriptors. */ @@ -492,7 +492,7 @@ e1000_t *e; { if ((e->rx_desc = alloc_contig(sizeof(e1000_rx_desc_t) * e->rx_desc_count, AC_ALIGN4K, - &rx_desc_p)) == NULL) { + &e->rx_desc_p)) == NULL) { panic("failed to allocate RX descriptors"); } memset(e->rx_desc, 0, sizeof(e1000_rx_desc_t) * e->rx_desc_count); @@ -521,7 +521,7 @@ e1000_t *e; { if ((e->tx_desc = alloc_contig(sizeof(e1000_tx_desc_t) * e->tx_desc_count, AC_ALIGN4K, - &tx_desc_p)) == NULL) { + &e->tx_desc_p)) == NULL) { panic("failed to allocate TX descriptors"); } memset(e->tx_desc, 0, sizeof(e1000_tx_desc_t) * e->tx_desc_count); @@ -546,7 +546,7 @@ e1000_t *e; /* * Setup the receive ring registers. */ - e1000_reg_write(e, E1000_REG_RDBAL, rx_desc_p); + e1000_reg_write(e, E1000_REG_RDBAL, e->rx_desc_p); e1000_reg_write(e, E1000_REG_RDBAH, 0); e1000_reg_write(e, E1000_REG_RDLEN, e->rx_desc_count * sizeof(e1000_rx_desc_t)); @@ -558,7 +558,7 @@ e1000_t *e; /* * Setup the transmit ring registers. */ - e1000_reg_write(e, E1000_REG_TDBAL, tx_desc_p); + e1000_reg_write(e, E1000_REG_TDBAL, e->tx_desc_p); e1000_reg_write(e, E1000_REG_TDBAH, 0); e1000_reg_write(e, E1000_REG_TDLEN, e->tx_desc_count * sizeof(e1000_tx_desc_t)); diff --git a/drivers/e1000/e1000.h b/drivers/e1000/e1000.h index 0124c3353..d1e26dd72 100644 --- a/drivers/e1000/e1000.h +++ b/drivers/e1000/e1000.h @@ -155,11 +155,13 @@ typedef struct e1000 int eeprom_addr_off; /**< Offset of the EERD.ADDR field. */ e1000_rx_desc_t *rx_desc; /**< Receive Descriptor table. */ + phys_bytes rx_desc_p; /**< Physical Receive Descriptor Address. */ int rx_desc_count; /**< Number of Receive Descriptors. */ char *rx_buffer; /**< Receive buffer returned by malloc(). */ int rx_buffer_size; /**< Size of the receive buffer. */ e1000_tx_desc_t *tx_desc; /**< Transmit Descriptor table. */ + phys_bytes tx_desc_p; /**< Physical Transmit Descriptor Address. */ int tx_desc_count; /**< Number of Transmit Descriptors. */ char *tx_buffer; /**< Transmit buffer returned by malloc(). */ int tx_buffer_size; /**< Size of the transmit buffer. */