Subject: Re: [PATCH net-next 2/9] bonding: remove __get_first_port()

From: Veaceslav Falico <[email-masked]>
Date: Fri, 27 Sep 2013 17:05:17 +0200

On Fri, Sep 27, 2013 at 04:58:25PM +0200, Veaceslav Falico wrote:
>On Fri, Sep 27, 2013 at 03:50:12PM +0100, David Laight wrote:
>>>@@ -2104,8 +2091,11 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
>>>
>>> 	// check if agg_select_timer timer after initialize is timed out
>>> 	if (BOND_AD_INFO(bond).agg_select_timer && !(--BOND_AD_INFO(bond).agg_select_timer)) {
>>>+		slave = bond_first_slave(bond);
>>>+		port = slave ? &(SLAVE_AD_INFO(slave).port) : NULL;
>>>+
>>> 		// select the active aggregator for the bond
>>>-		if ((port = __get_first_port(bond))) {
>>>+		if (port) {
>>> 			if (!port->slave) {
>>> 				pr_warning("%s: Warning: bond's first port is uninitialized\n",
>>> 					   bond->dev->name);
>>>--
>>
>>Looks like that could be:
>>		slave = bond_first_slave(bond);
>>		if (slave) {
>>			port = SLAVE_AD_INFO(slave).port;
>>and I assume 'slave == port->slave' so there is no need for the latter check?
>
>I've also fallen to this trap at first - slave->port can (virtually) be
>NULL, and this way we'll panic on "if (!port->slave)".

Err, forgot to address the 'slave == port->slave' - yes, virtually it
should be - if it's initialized (and, it should be) - however, as I've
stated in the cover letter - there are *tons* of cleanups/optimizations of
these kind that might be done here - and not to mix cleanups/optimizations
with the thing that these patches should do (remove bond_next_slave) - I've
decided to leave it as close to the original as possible.

>>	David