[dpdk-dev,v2,07/10] app/test: use struct ether_addr instead of a byte array cast

Message ID 1434735293-15469-8-git-send-email-cchemparathy@ezchip.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Cyril Chemparathy June 19, 2015, 5:34 p.m. UTC
  This patch instantiates struct ether_addr instead of type casting a
uint8_t pointer to the same structure.  The type cast breaks on
machines that enforce strict alignment.

Acked-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>
---
 app/test/test_pmd_perf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Stephen Hemminger June 22, 2015, 1:56 a.m. UTC | #1
On Fri, 19 Jun 2015 10:34:50 -0700
Cyril Chemparathy <cchemparathy@ezchip.com> wrote:

> +	static struct ether_addr src_mac =
> +		{ { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF } };
> +	static struct ether_addr dst_mac =
> +		{ { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA } };
>  

Should have been const (in original code).
  
Cyril Chemparathy June 22, 2015, 4:40 p.m. UTC | #2
On Sun, 21 Jun 2015 21:56:24 -0400
Stephen Hemminger <stephen@networkplumber.org> wrote:

> On Fri, 19 Jun 2015 10:34:50 -0700
> Cyril Chemparathy <cchemparathy@ezchip.com> wrote:
> 
> > +	static struct ether_addr src_mac =
> > +		{ { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF } };
> > +	static struct ether_addr dst_mac =
> > +		{ { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA } };
> >  
> 
> Should have been const (in original code).

Thanks.  Fixed for v3.  I'll be happy to resend the series unless you
have comments on the rest of the patches.
  

Patch

diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index 1fd6843..c5253d0 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -228,13 +228,13 @@  init_traffic(struct rte_mempool *mp,
 	struct ipv4_hdr pkt_ipv4_hdr;
 	struct udp_hdr pkt_udp_hdr;
 	uint32_t pktlen;
-	static uint8_t src_mac[] = { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF };
-	static uint8_t dst_mac[] = { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA };
-
+	static struct ether_addr src_mac =
+		{ { 0x00, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF } };
+	static struct ether_addr dst_mac =
+		{ { 0x00, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA } };
 
 	initialize_eth_header(&pkt_eth_hdr,
-		(struct ether_addr *)src_mac,
-		(struct ether_addr *)dst_mac, ETHER_TYPE_IPv4, 0, 0);
+		&src_mac, &dst_mac, ETHER_TYPE_IPv4, 0, 0);
 
 	pktlen = initialize_ipv4_header(&pkt_ipv4_hdr,
 					IPV4_ADDR(10, 0, 0, 1),