]> Zhao Yanbai Git Server - minix.git/commitdiff
e1000: resolve Coverity warnings
authorDavid van Moolenbroek <david@minix3.org>
Fri, 3 Aug 2012 16:10:24 +0000 (16:10 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Mon, 6 Aug 2012 16:18:36 +0000 (16:18 +0000)
drivers/e1000/e1000.c
drivers/e1000/e1000.h

index e0fe93db965286681fab76d2687b7ab8315383b1..47f21f026c7b95160860f85d73a45435746fed6d 100644 (file)
@@ -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));
index 0124c3353cec1a93dc87875d3c48f7980b982c85..d1e26dd72876c1e9994802b7a62363b271a2c3f4 100644 (file)
@@ -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. */