From: <sameehj@amazon.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: Sameeh Jubran <sameehj@amazon.com>, <dwmw@amazon.com>,
<zorik@amazon.com>, <matua@amazon.com>, <saeedb@amazon.com>,
<msw@amazon.com>, <aliguori@amazon.com>, <nafea@amazon.com>,
<gtzalik@amazon.com>, <netanel@amazon.com>, <alisaidi@amazon.com>,
<benh@amazon.com>, <akiyano@amazon.com>
Subject: [PATCH V1 net 8/8] net: ena: gcc 8: fix compilation warning
Date: Wed, 1 May 2019 16:47:10 +0300 [thread overview]
Message-ID: <20190501134710.8938-9-sameehj@amazon.com> (raw)
In-Reply-To: <20190501134710.8938-1-sameehj@amazon.com>
From: Sameeh Jubran <sameehj@amazon.com>
GCC 8 contains a number of new warnings as well as enhancements to existing
checkers. The warning - Wstringop-truncation - warns for calls to bounded
string manipulation functions such as strncat, strncpy, and stpncpy that
may either truncate the copied string or leave the destination unchanged.
In our case the destination string length (32 bytes) is much shorter than
the source string (64 bytes) which causes this warning to show up. In
general the destination has to be at least a byte larger than the length
of the source string with strncpy for this warning not to showup.
This can be easily fixed by using strlcpy instead which already does the
truncation to the string. Documentation for this function can be
found here:
https://elixir.bootlin.com/linux/latest/source/lib/string.c#L141
Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
---
drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 03244155f74c..bc5997a5f809 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -2298,7 +2298,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev,
host_info->bdf = (pdev->bus->number << 8) | pdev->devfn;
host_info->os_type = ENA_ADMIN_OS_LINUX;
host_info->kernel_ver = LINUX_VERSION_CODE;
- strncpy(host_info->kernel_ver_str, utsname()->version,
+ strlcpy(host_info->kernel_ver_str, utsname()->version,
sizeof(host_info->kernel_ver_str) - 1);
host_info->os_dist = 0;
strncpy(host_info->os_dist_str, utsname()->release,
--
2.17.1
next prev parent reply other threads:[~2019-05-01 13:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-01 13:47 [PATCH V1 net 0/8] Bug fixes for ENA Ethernet driver sameehj
2019-05-01 13:47 ` [PATCH V1 net 1/8] net: ena: fix swapped parameters when calling ena_com_indirect_table_fill_entry sameehj
2019-05-01 13:47 ` [PATCH V1 net 2/8] net: ena: fix: set freed objects to NULL to avoid failing future allocations sameehj
2019-05-01 13:47 ` [PATCH V1 net 3/8] net: ena: fix: Free napi resources when ena_up() fails sameehj
2019-05-01 13:47 ` [PATCH V1 net 4/8] net: ena: fix incorrect test of supported hash function sameehj
2019-05-01 13:47 ` [PATCH V1 net 5/8] net: ena: fix return value of ena_com_config_llq_info() sameehj
2019-05-01 13:47 ` [PATCH V1 net 6/8] net: ena: improve latency by disabling adaptive interrupt moderation by default sameehj
2019-05-01 13:47 ` [PATCH V1 net 7/8] net: ena: fix ena_com_fill_hash_function() implementation sameehj
2019-05-01 13:47 ` sameehj [this message]
2019-05-04 4:17 ` [PATCH V1 net 0/8] Bug fixes for ENA Ethernet driver David Miller
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=20190501134710.8938-9-sameehj@amazon.com \
--to=sameehj@amazon.com \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=benh@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw@amazon.com \
--cc=gtzalik@amazon.com \
--cc=matua@amazon.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=saeedb@amazon.com \
--cc=zorik@amazon.com \
/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).