[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170714.090346.1021214085207295498.davem@davemloft.net>
Date: Fri, 14 Jul 2017 09:03:46 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: arnd@...db.de
Cc: linux-kernel@...r.kernel.org, Yuval.Mintz@...ium.com,
ariel.elior@...ium.com, everest-linux-l2@...ium.com,
gregkh@...uxfoundation.org, torvalds@...ux-foundation.org,
linux@...ck-us.net, akpm@...ux-foundation.org,
netdev@...r.kernel.org, jejb@...ux.vnet.ibm.com,
martin.petersen@...cle.com, linux-scsi@...r.kernel.org,
x86@...nel.org, colin.king@...onical.com, tremyfr@...il.com
Subject: Re: [PATCH 10/22] bnx2x: fix format overflow warning
From: Arnd Bergmann <arnd@...db.de>
Date: Fri, 14 Jul 2017 14:07:02 +0200
> gcc notices that large queue numbers would overflow the queue name
> string:
>
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c: In function 'bnx2x_get_strings':
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c:3165:25: error: '%d' directive writing between 1 and 10 bytes into a region of size 5 [-Werror=format-overflow=]
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c:3165:25: note: directive argument in the range [0, 2147483647]
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c:3165:5: note: 'sprintf' output between 2 and 11 bytes into a destination of size 5
>
> There is a hard limit in place that makes the number at most two
> digits, so the code is fine. This changes it to use snprintf()
> to truncate instead of overflowing, which shuts up that warning.
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
Applied.
Powered by blists - more mailing lists