From mboxrd@z Thu Jan  1 00:00:00 1970
From: Bernhard Bitsch <Bernhard.Bitsch@gmx.de>
To: development@lists.ipfire.org
Subject: Aw: Re: [PATCH v3 2/4] Network::network2bin: return an empty list in
 case of error
Date: Wed, 14 Feb 2018 23:59:57 +0100
Message-ID:
 <trinity-59524d43-a888-4fe2-ad3f-f4139c111e90-1518649197808@3c-app-gmx-bs52>
In-Reply-To: <1518646332.6463.4.camel@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============5512691912015408913=="
List-Id: <development.lists.ipfire.org>

--===============5512691912015408913==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Hello,

if I can help, I could look at this also.
Some "cosmetics" (indentions, placing { on the line of 'if', ... ) could make=
 the code more readable. These produce some greater patches without a gain in=
 correctness but in maintainability.

Regards,
Bernhard Bitsch

> Gesendet: Mittwoch, 14. Februar 2018 um 23:12 Uhr
> Von: "Michael Tremer" <michael.tremer(a)ipfire.org>
> An: "Bernhard Held" <berny156(a)gmx.de>, development(a)lists.ipfire.org
> Betreff: Re: [PATCH v3 2/4] Network::network2bin: return an empty list in c=
ase of error
>
> Hello,
>=20
> did you check if any other functions need to be changed in order to
> reflect this change?
>=20
> Many functions use the output of this one.
>=20
> -Michael
>=20
> On Wed, 2018-02-14 at 20:35 +0100, Bernhard Held wrote:
> > 'return undef;' will always return a single value 'undef' even in list co=
ntext.
> >=20
> > sub foo { return undef }
> > if ( my @x =3D foo() ) {
> > 	print "oops, we think we got a result";
> > }
> > ---
> >  config/cfgroot/network-functions.pl | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >=20
> > diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network=
-functions.pl
> > index 070e14d0f..7cd56f799 100644
> > --- a/config/cfgroot/network-functions.pl
> > +++ b/config/cfgroot/network-functions.pl
> > @@ -139,7 +139,7 @@ sub network2bin($) {
> >  	my $netmask_bin =3D &ip2bin($netmask);
> > =20
> >  	if (!defined $address_bin || !defined $netmask_bin) {
> > -		return undef;
> > +		return ();
> >  	}
> > =20
> >  	my $network_start =3D $address_bin & $netmask_bin;
>=20

--===============5512691912015408913==--