DPDK patches and discussions
 help / color / mirror / Atom feed
* Re: [dpdk-dev] [PATCH 1/2 v2] fix incorrect snprintf args
       [not found] <20140624111333.721633f7@nehalam.linuxnetplumber.net>
@ 2014-06-24 18:14 ` Stephen Hemminger
  2014-06-27  0:53   ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2014-06-24 18:14 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Now that snprintf is used, Gcc finds more uses of unsafe arguments.
Fix where found. Some of these may have already been fixed by
other patches on the mailing list.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
v2 - no changes to this part


--- a/lib/librte_kni/rte_kni.c	2014-06-24 08:48:55.758031238 -0700
+++ b/lib/librte_kni/rte_kni.c	2014-06-24 08:48:55.754031210 -0700
@@ -158,7 +158,7 @@ rte_kni_alloc(struct rte_mempool *pktmbu
 		}
 	}
 
-	snprintf(intf_name, RTE_KNI_NAMESIZE, conf->name);
+	snprintf(intf_name, RTE_KNI_NAMESIZE, "%s", conf->name);
 	snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "KNI_INFO_%s", intf_name);
 	mz = kni_memzone_reserve(mz_name, sizeof(struct rte_kni),
 				SOCKET_ID_ANY, 0);
@@ -184,8 +184,8 @@ rte_kni_alloc(struct rte_mempool *pktmbu
 	dev_info.group_id = conf->group_id;
 	dev_info.mbuf_size = conf->mbuf_size;
 
-	snprintf(ctx->name, RTE_KNI_NAMESIZE, intf_name);
-	snprintf(dev_info.name, RTE_KNI_NAMESIZE, intf_name);
+	snprintf(ctx->name, RTE_KNI_NAMESIZE, "%s", intf_name);
+	snprintf(dev_info.name, RTE_KNI_NAMESIZE, "%s", intf_name);
 
 	RTE_LOG(INFO, KNI, "pci: %02x:%02x:%02x \t %02x:%02x\n",
 		dev_info.bus, dev_info.devid, dev_info.function,
@@ -291,7 +291,7 @@ rte_kni_release(struct rte_kni *kni)
 	if (!kni || !kni->in_use)
 		return -1;
 
-	snprintf(dev_info.name, sizeof(dev_info.name), kni->name);
+	snprintf(dev_info.name, sizeof(dev_info.name), "%s", kni->name);
 	if (ioctl(kni_fd, RTE_KNI_IOCTL_RELEASE, &dev_info) < 0) {
 		RTE_LOG(ERR, KNI, "Fail to release kni device\n");
 		return -1;
--- a/app/test/test_cmdline_etheraddr.c	2014-06-24 08:35:31.820146456 -0700
+++ b/app/test/test_cmdline_etheraddr.c	2014-06-24 08:54:35.396486084 -0700
@@ -147,7 +147,7 @@ test_parse_etheraddr_invalid_param(void)
 
 	/* copy string to buffer */
 	snprintf(buf, sizeof(buf), "%s",
-			ether_addr_valid_strs[0]);
+		 ether_addr_valid_strs[0].str);
 
 	ret = cmdline_parse_etheraddr(NULL, buf, NULL);
 	if (ret == -1) {
--- a/app/test/test_eal_flags.c	2014-06-24 08:35:31.820146456 -0700
+++ b/app/test/test_eal_flags.c	2014-06-24 08:53:16.623916364 -0700
@@ -268,7 +268,7 @@ get_current_prefix(char * prefix, int si
 
 	/* copy string all the way from second char up to start of _config */
 	snprintf(prefix, size, "%.*s",
-			strnlen(buf, sizeof(buf)) - sizeof("_config"), &buf[1]);
+		 (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")), &buf[1]);
 
 	return prefix;
 }
--- a/app/test/test_mp_secondary.c	2014-06-24 08:35:31.820146456 -0700
+++ b/app/test/test_mp_secondary.c	2014-06-24 08:50:27.706700011 -0700
@@ -103,7 +103,7 @@ get_current_prefix(char * prefix, int si
 
 	/* copy string all the way from second char up to start of _config */
 	snprintf(prefix, size, "%.*s",
-			strnlen(buf, sizeof(buf)) - sizeof("_config"), &buf[1]);
+		 (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")), &buf[1]);
 
 	return prefix;
 }

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

* Re: [dpdk-dev] [PATCH 1/2 v2] fix incorrect snprintf args
  2014-06-24 18:14 ` [dpdk-dev] [PATCH 1/2 v2] fix incorrect snprintf args Stephen Hemminger
@ 2014-06-27  0:53   ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2014-06-27  0:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2014-06-24 11:14, Stephen Hemminger:
> Now that snprintf is used, Gcc finds more uses of unsafe arguments.
> Fix where found. Some of these may have already been fixed by
> other patches on the mailing list.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

It was already fixed by Bruce's patch:
	http://dpdk.org/browse/dpdk/commit/?id=e8ed6c78177

Thanks
-- 
Thomas

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

end of thread, other threads:[~2014-06-27  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20140624111333.721633f7@nehalam.linuxnetplumber.net>
2014-06-24 18:14 ` [dpdk-dev] [PATCH 1/2 v2] fix incorrect snprintf args Stephen Hemminger
2014-06-27  0:53   ` Thomas Monjalon

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).