tg3: Increase buffer size for IRQ label
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 16 Oct 2024 09:05:54 +0000 (12:05 +0300)
committerAndrew Lunn <andrew@lunn.ch>
Fri, 18 Oct 2024 02:24:24 +0000 (21:24 -0500)
GCC is not happy with the current code, e.g.:

.../tg3.c:11313:37: error: ‘-txrx-’ directive output may be truncated writing 6 bytes into a region of size between 1 and 16 [-Werror=format-truncation=]
11313 |                                  "%s-txrx-%d", tp->dev->name, irq_num);
      |                                     ^~~~~~
.../tg3.c:11313:34: note: using the range [-21474836482147483647] for directive argument
11313 |                                  "%s-txrx-%d", tp->dev->name, irq_num);

When `make W=1` is supplied, this prevents kernel building. Fix it by
increasing the buffer size for IRQ label and use sizeoF() instead of
hard coded constants.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Message-ID: <20241016090647.691022-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/broadcom/tg3.h

index d5916bbc1b3a827cbbb56ab36e35591d2b32db57..c20958607dd866b4a719b6d7940b5d5de35c5946 100644 (file)
@@ -11342,18 +11342,17 @@ static int tg3_request_irq(struct tg3 *tp, int irq_num)
        else {
                name = &tnapi->irq_lbl[0];
                if (tnapi->tx_buffers && tnapi->rx_rcb)
-                       snprintf(name, IFNAMSIZ,
+                       snprintf(name, sizeof(tnapi->irq_lbl),
                                 "%s-txrx-%d", tp->dev->name, irq_num);
                else if (tnapi->tx_buffers)
-                       snprintf(name, IFNAMSIZ,
+                       snprintf(name, sizeof(tnapi->irq_lbl),
                                 "%s-tx-%d", tp->dev->name, irq_num);
                else if (tnapi->rx_rcb)
-                       snprintf(name, IFNAMSIZ,
+                       snprintf(name, sizeof(tnapi->irq_lbl),
                                 "%s-rx-%d", tp->dev->name, irq_num);
                else
-                       snprintf(name, IFNAMSIZ,
+                       snprintf(name, sizeof(tnapi->irq_lbl),
                                 "%s-%d", tp->dev->name, irq_num);
-               name[IFNAMSIZ-1] = 0;
        }
 
        if (tg3_flag(tp, USING_MSI) || tg3_flag(tp, USING_MSIX)) {
index cf1b2b123c7ee9a906aa516b43b5452f778c8895..b473f8014d9c0d04baaa912136099da799f8399d 100644 (file)
@@ -3033,7 +3033,7 @@ struct tg3_napi {
        dma_addr_t                      rx_rcb_mapping;
        dma_addr_t                      tx_desc_mapping;
 
-       char                            irq_lbl[IFNAMSIZ];
+       char                            irq_lbl[IFNAMSIZ + 6 + 10]; /* name + "-txrx-" + %d */
        unsigned int                    irq_vec;
 };