[PATCH 06/21] net: dhcp: Do not overwrite serverip if it is valid

Sascha Hauer s.hauer at pengutronix.de
Mon Nov 27 23:42:08 PST 2017


Hi Sam,

On Sat, Nov 25, 2017 at 05:36:23PM +0100, Sam Ravnborg wrote:
> Hi Sasha.
> 
> >  }
> >  
> > -void net_set_serverip(IPaddr_t ip)
> > +void net_set_serverip(IPaddr_t ip, bool overwrite)
> >  {
> > +	if (net_serverip && !overwrite)
> > +		return;
> > +
> >  	net_serverip = ip;
> >  }
> 
> An alternative solution had been to implement two functions:
> net_set_serverip() - that would always set the ip.
> net_set_empty_serverip() - update ip only if empty
> 
> This is more readable than a boolean flag which
> you always need to look up to check the interpretation of.

Good idea. Just did that.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list