From 93127b0f9515be4b8f1365d7670744fcac0ade16 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 17 Aug 2016 09:30:50 +0200 Subject: trafgen: proto: Initialize lower proto header pointer on declaration Assign the pointer to the lower layer header on declaration instead of a separate line. Signed-off-by: Tobias Klauser --- trafgen_l2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/trafgen_l2.c b/trafgen_l2.c index f09b2a6..866559c 100644 --- a/trafgen_l2.c +++ b/trafgen_l2.c @@ -67,11 +67,9 @@ static struct proto_field vlan_fields[] = { static void vlan_header_init(struct proto_hdr *hdr) { - struct proto_hdr *lower; + struct proto_hdr *lower = proto_lower_default_add(hdr, PROTO_ETH); uint16_t lower_etype = 0; - lower = proto_lower_default_add(hdr, PROTO_ETH); - proto_header_fields_add(hdr, vlan_fields, array_size(vlan_fields)); if (lower->ops->id == PROTO_ETH) @@ -110,9 +108,7 @@ static struct proto_field arp_fields[] = { static void arp_header_init(struct proto_hdr *hdr) { - struct proto_hdr *lower; - - lower = proto_lower_default_add(hdr, PROTO_ETH); + struct proto_hdr *lower = proto_lower_default_add(hdr, PROTO_ETH); if (lower->ops->id == PROTO_ETH) { const uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -- cgit v1.2.3-54-g00ecf