[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20170619.102732.757903859980010467.davem@davemloft.net>
Date: Mon, 19 Jun 2017 10:27:32 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: gvaradar@...co.com
Cc: netdev@...r.kernel.org, benve@...co.com
Subject: Re: [PATCH net-next] enic: use kasprintf instead of snprintf
From: Govindarajulu Varadarajan <gvaradar@...co.com>
Date: Sun, 18 Jun 2017 22:05:37 -0700
> With -Wformat-truncation=, gcc throws the following warning. Instead of
> using snprintf, use kasprintf and allocate string size as needed.
>
> drivers/net/ethernet/cisco/enic/enic_main.c: In function ‘enic_open’:
> drivers/net/ethernet/cisco/enic/enic_main.c:1740:15: warning: ‘%u’ directive output may be truncated writing between 1 and 2 bytes into a region of size between 1 and 12 [-Wformat-truncation=]
> "%.11s-rx-%u", netdev->name, i);
> ^~
> drivers/net/ethernet/cisco/enic/enic_main.c:1740:5: note: directive argument in the range [0, 16]
> "%.11s-rx-%u", netdev->name, i);
> ^~~~~~~~~~~~~
> drivers/net/ethernet/cisco/enic/enic_main.c:1738:4: note: ‘snprintf’ output between 6 and 18 bytes into a destination of size 16
> snprintf(enic->msix[intr].devname,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> sizeof(enic->msix[intr].devname),
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> "%.11s-rx-%u", netdev->name, i);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/cisco/enic/enic_main.c:1751:5: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
> "%.11s-tx-%u", netdev->name, i);
> ^~~~~~~~~~~~~
>
> also increment the version.
>
> Signed-off-by: Govindarajulu Varadarajan <gvaradar@...co.com>
Using dynamic allocation is overkill for this problem.
Powered by blists - more mailing lists