From: David Miller <davem@davemloft.net>
To: gvaradar@cisco.com
Cc: netdev@vger.kernel.org, benve@cisco.com
Subject: Re: [PATCH net-next] enic: use kasprintf instead of snprintf
Date: Mon, 19 Jun 2017 10:27:32 -0400 (EDT) [thread overview]
Message-ID: <20170619.102732.757903859980010467.davem@davemloft.net> (raw)
In-Reply-To: <20170619050537.6393-1-gvaradar@cisco.com>
From: Govindarajulu Varadarajan <gvaradar@cisco.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@cisco.com>
Using dynamic allocation is overkill for this problem.
prev parent reply other threads:[~2017-06-19 14:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 5:05 [PATCH net-next] enic: use kasprintf instead of snprintf Govindarajulu Varadarajan
2017-06-19 5:40 ` Joe Perches
2017-06-19 5:55 ` Govindarajulu Varadarajan
2017-06-19 5:59 ` Joe Perches
2017-06-19 14:27 ` David Miller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170619.102732.757903859980010467.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=benve@cisco.com \
--cc=gvaradar@cisco.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).