DPDK patches and discussions
 help / color / mirror / Atom feed
From: Julien Cretin <julien.cretin@trust-in-soft.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 3/3] app/testpmd: fix incompatible sign for printf arguments
Date: Mon, 12 May 2014 17:35:11 +0200	[thread overview]
Message-ID: <1399908911-18829-4-git-send-email-julien.cretin@trust-in-soft.com> (raw)
In-Reply-To: <1399908911-18829-1-git-send-email-julien.cretin@trust-in-soft.com>

The socket_id member of struct rte_port is an unsigned int while the d
conversion specifier of printf expects an int.

The addr_bytes member of struct ether_addr is an array of uint8_t
while the X conversion specifier of printf expects an unsigned int.
Values of type uint8_t are promoted to type int when used in the
ellipsis notation of a function.

These minor bugs were found using TrustInSoft Analyzer.

Signed-off-by: Julien Cretin <julien.cretin@trust-in-soft.com>
---
 app/test-pmd/config.c  | 16 ++++++++--------
 app/test-pmd/testpmd.c |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1feb133..134bf07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -100,12 +100,12 @@ static void
 print_ethaddr(const char *name, struct ether_addr *eth_addr)
 {
 	printf("%s%02X:%02X:%02X:%02X:%02X:%02X", name,
-	       eth_addr->addr_bytes[0],
-	       eth_addr->addr_bytes[1],
-	       eth_addr->addr_bytes[2],
-	       eth_addr->addr_bytes[3],
-	       eth_addr->addr_bytes[4],
-	       eth_addr->addr_bytes[5]);
+	       (unsigned int)eth_addr->addr_bytes[0],
+	       (unsigned int)eth_addr->addr_bytes[1],
+	       (unsigned int)eth_addr->addr_bytes[2],
+	       (unsigned int)eth_addr->addr_bytes[3],
+	       (unsigned int)eth_addr->addr_bytes[4],
+	       (unsigned int)eth_addr->addr_bytes[5]);
 }
 
 void
@@ -256,7 +256,7 @@ port_infos_display(portid_t port_id)
 	printf("\n%s Infos for port %-2d %s\n",
 	       info_border, port_id, info_border);
 	print_ethaddr("MAC address: ", &port->eth_addr);
-	printf("\nConnect to socket: %d", port->socket_id);
+	printf("\nConnect to socket: %u", port->socket_id);
 
 	if (port_numa[port_id] != NUMA_NO_CONFIG) {
 		mp = mbuf_pool_find(port_numa[port_id]);
@@ -264,7 +264,7 @@ port_infos_display(portid_t port_id)
 			printf("\nmemory allocation on the socket: %d",
 							port_numa[port_id]);
 	} else
-		printf("\nmemory allocation on the socket: %d",port->socket_id);
+		printf("\nmemory allocation on the socket: %u",port->socket_id);
 
 	printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down"));
 	printf("Link speed: %u Mbps\n", (unsigned) link.link_speed);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9c56914..55a5ea1 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1250,7 +1250,7 @@ start_port(portid_t pid)
 		if (port->need_reconfig > 0) {
 			port->need_reconfig = 0;
 
-			printf("Configuring Port %d (socket %d)\n", pi,
+			printf("Configuring Port %d (socket %u)\n", pi,
 					port->socket_id);
 			/* configure port */
 			diag = rte_eth_dev_configure(pi, nb_rxq, nb_txq,
-- 
1.9.1

  parent reply	other threads:[~2014-05-12 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 15:35 [dpdk-dev] [PATCH 0/3] Various patches Julien Cretin
2014-05-12 15:35 ` [dpdk-dev] [PATCH 1/3] app/testpmd: fix minor signed overflow in a constant Julien Cretin
2014-05-12 15:35 ` [dpdk-dev] [PATCH 2/3] mem: remove redundant check in optimize_object_size Julien Cretin
2014-05-12 15:35 ` Julien Cretin [this message]
2014-05-14  9:26 ` [dpdk-dev] [PATCH 0/3] Various patches Thomas Monjalon

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=1399908911-18829-4-git-send-email-julien.cretin@trust-in-soft.com \
    --to=julien.cretin@trust-in-soft.com \
    --cc=dev@dpdk.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).