All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1
@ 2017-09-26 18:48 Felix Manlunas
  2017-09-27  9:04 ` David Laight
  2017-09-30  4:29 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Felix Manlunas @ 2017-09-26 18:48 UTC (permalink / raw)
  To: davem; +Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla

From: Satanand Burla <satananda.burla@cavium.com>

gcc 7.1.1 with -Wformat-truncation reports these warnings:

drivers/net/ethernet/cavium/liquidio/lio_core.c: In function `octeon_setup_interrupt':
drivers/net/ethernet/cavium/liquidio/lio_core.c:1003:41: warning: `%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 13 [-Wformat-truncation=]
       INTRNAMSIZ, "LiquidIO%u-pf%u-rxtx-%u",
                                         ^~
drivers/net/ethernet/cavium/liquidio/lio_core.c:1003:19: note: directive argument in the range [0, 2147483647]
       INTRNAMSIZ, "LiquidIO%u-pf%u-rxtx-%u",
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/cavium/liquidio/lio_core.c:1002:5: note: `snprintf' output between 21 and 43 bytes into a destination of size 32
     snprintf(&queue_irq_names[IRQ_NAME_OFF(i)],
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       INTRNAMSIZ, "LiquidIO%u-pf%u-rxtx-%u",
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       oct->octeon_id, oct->pf_num, i);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/cavium/liquidio/lio_core.c:1008:41: warning: `%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 13 [-Wformat-truncation=]
       INTRNAMSIZ, "LiquidIO%u-vf%u-rxtx-%u",
                                         ^~
drivers/net/ethernet/cavium/liquidio/lio_core.c:1008:19: note: directive argument in the range [0, 2147483647]
       INTRNAMSIZ, "LiquidIO%u-vf%u-rxtx-%u",
                   ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/cavium/liquidio/lio_core.c:1007:5: note: `snprintf' output between 21 and 43 bytes into a destination of size 32
     snprintf(&queue_irq_names[IRQ_NAME_OFF(i)],
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       INTRNAMSIZ, "LiquidIO%u-vf%u-rxtx-%u",
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       oct->octeon_id, oct->vf_num, i);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix them by changing the type of the "i" local variable from int to short.

Signed-off-by: Satanand Burla <satananda.burla@cavium.com>
Signed-off-by: Felix Manlunas <felix.manlunas@cavium.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 23f6b60..55c5d44 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -899,11 +899,12 @@ int octeon_setup_interrupt(struct octeon_device *oct, u32 num_ioqs)
 {
 	struct msix_entry *msix_entries;
 	char *queue_irq_names = NULL;
-	int i, num_interrupts = 0;
+	int num_interrupts = 0;
 	int num_alloc_ioq_vectors;
 	char *aux_irq_name = NULL;
 	int num_ioq_vectors;
 	int irqret, err;
+	short i;
 
 	oct->num_msix_irqs = num_ioqs;
 	if (oct->msix_on) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1
  2017-09-26 18:48 [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1 Felix Manlunas
@ 2017-09-27  9:04 ` David Laight
  2017-09-30  4:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2017-09-27  9:04 UTC (permalink / raw)
  To: 'Felix Manlunas', davem
  Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla

From: Felix Manlunas
> Sent: 26 September 2017 19:48
> gcc 7.1.1 with -Wformat-truncation reports these warnings:
> 
> drivers/net/ethernet/cavium/liquidio/lio_core.c: In function `octeon_setup_interrupt':
> drivers/net/ethernet/cavium/liquidio/lio_core.c:1003:41: warning: `%u' directive output may be
> truncated writing between 1 and 10 bytes into a region of size between 0 and 13 [-Wformat-truncation=]
>        INTRNAMSIZ, "LiquidIO%u-pf%u-rxtx-%u",
...
> Fix them by changing the type of the "i" local variable from int to short.

That probably adds pointless code bloat by forcing the compiler to
keep masking the value with 0xffff after every arithmetic operation.

About the only architecture that doesn't suffer the penalty is x86.

Until the compiler can correctly track the domain of values (and
be given hints about the domains) this warning is, IMHO, OTT.

	David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1
  2017-09-26 18:48 [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1 Felix Manlunas
  2017-09-27  9:04 ` David Laight
@ 2017-09-30  4:29 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-09-30  4:29 UTC (permalink / raw)
  To: felix.manlunas; +Cc: netdev, raghu.vatsavayi, derek.chickles, satananda.burla

From: Felix Manlunas <felix.manlunas@cavium.com>
Date: Tue, 26 Sep 2017 11:48:27 -0700

> From: Satanand Burla <satananda.burla@cavium.com>
> 
> gcc 7.1.1 with -Wformat-truncation reports these warnings:
> 
> drivers/net/ethernet/cavium/liquidio/lio_core.c: In function `octeon_setup_interrupt':
> drivers/net/ethernet/cavium/liquidio/lio_core.c:1003:41: warning: `%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 13 [-Wformat-truncation=]
>        INTRNAMSIZ, "LiquidIO%u-pf%u-rxtx-%u",
>                                          ^~

Please just increase INTRNAMSIZ as needed.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-30  4:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26 18:48 [PATCH net-next] liquidio: fix format truncation warning reported by gcc 7.1.1 Felix Manlunas
2017-09-27  9:04 ` David Laight
2017-09-30  4:29 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.