i40e: make use of hlist_for_each_entry_continue
Subsystems (2)
PATCH 1/1 i40e: make use of hlist_for_each_entry_continue
Replace a complex if->continue->else->break construction in i40e_next_filter. We can simply use hlist_for_each_entry_continue instead. This drops a lot of confusing code. The resulting code is much easier to understand the intention, and follows the more normal pattern for using hlist loops. We could have also used a break with a "return next" at the end of the function, instead of return NULL, but the current implementation is explicitly clear that when you reach the end of the loop you get a NULL value. The alternative construction is less clear since the reader would have to know that next is NULL at the end of the loop.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -11
@@ -1817,19 +1817,12 @@ static void i40e_undo_add_filter_entries(struct i40e_vsi *vsi,static struct i40e_new_mac_filter *i40e_next_filter (struct i40e_new_mac_filter *next) { -while (next) { - next =hlist_entry (next->hlist.next, - typeof(struct i40e_new_mac_filter), - hlist); - -/* keep going if we found a broadcast filter */ -if (next &&is_broadcast_ether_addr (next->f->macaddr)) -continue ; - -break ; +hlist_for_each_entry_continue (next, hlist) { +if (!is_broadcast_ether_addr (next->f->macaddr)) +return next; } -return next; +return NULL ; }/**
Signature · 1 line
2.12.0.rc1.272.g5157a0d593b8
Bowers
PATCH 1/1 i40e: make use of hlist_for_each_entry_continue
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Tuesday, March 7, 2017 3:18 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH] i40e: make use ofhlist_for_each_entry_continueReplace a complex
if->continue->else->breakconstruction ini40e_next_filter. We can simply usehlist_for_each_entry_continueinstead. This drops a lot of confusing code. The resulting code is much easier to understand the intention, and follows the more normal pattern for using hlist loops. We could have also used a break with a "return next" at the end of the function, instead of return NULL, but the current implementation is explicitly clear that when you reach the end of the loop you get a NULL value. The alternative construction is less clear since the reader would have to know that next is NULL at the end of the loop.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>Change-Id Ife74ca451dd79d7f0d93c672bd42092d324d4a03--- drivers/net/ethernet/intel/i40e/i40e_main.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)