From owner-freebsd-net@FreeBSD.ORG Thu May 20 14:11:00 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 078FA16A4CE; Thu, 20 May 2004 14:11:00 -0700 (PDT) Received: from darkness.comp.waw.pl (darkness.comp.waw.pl [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 906D143D3F; Thu, 20 May 2004 14:10:59 -0700 (PDT) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 290C8ACAE3; Thu, 20 May 2004 23:10:58 +0200 (CEST) Date: Thu, 20 May 2004 23:10:58 +0200 From: Pawel Jakub Dawidek To: Andre Oppermann Message-ID: <20040520211058.GX845@darkness.comp.waw.pl> References: <20040520173012.GR845@darkness.comp.waw.pl> <40AD1CBA.4CB46233@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RM4LNcG2CLff9Gl5" Content-Disposition: inline In-Reply-To: <40AD1CBA.4CB46233@freebsd.org> User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: freebsd-net@freebsd.org Subject: Re: Socket selection. X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2004 21:11:00 -0000 --RM4LNcG2CLff9Gl5 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 20, 2004 at 11:01:46PM +0200, Andre Oppermann wrote: +> Pawel Jakub Dawidek wrote: +> >=20 +> > Hello. +> >=20 +> > In in_pcblookup_hash() function, in the last loop if we find exact +> > match, we return immediately, if it is "wild", we store a pointer and +> > we countinue looking for exact match. +> > I wonder if this is ok, that we change pointer every time we find a +> > "wild" match. Is it inteded? Shouldn't it be: +> >=20 +> > http://people.freebsd.org/~pjd/patches/in_pcb.c.2.patch +>=20 +> No. This is a stack variable which is unconditionally initialized to +> NULL a few lines earlier. Checking for variable =3D=3D NULL is always +> going to be true and makes your 'optimization' just redundand. But we have loop there: local_wild =3D NULL; [...] LIST_FOREACH(...) { [...] local_wild =3D ; [...] } Isn't that possible that local_wild will be set few times? +> > While I'm here, I want to improve code readability a bit: +> >=20 +> > http://people.freebsd.org/~pjd/patches/in_pcb.c.3.patch +> >=20 +> > Is it ok? +>=20 +> No. You change the logic of the 'if' statements to something totally +> different. This ain't going to work in any way. Hmm, no: for (...) { if (a =3D=3D b && c =3D=3D d) { /* do something */ } /* nothing here */ } is equivalent to: for (...) { if (a !=3D b || c !=3D d) continue; /* do something */ } isn't it? --=20 Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! --RM4LNcG2CLff9Gl5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFArR7iForvXbEpPzQRAt/BAJoCHKo4w3fVXfRd8vIIhwj5V9NM/ACaApAM dSy1/HgFoYXDGBrp9GKstUw= =Q0QC -----END PGP SIGNATURE----- --RM4LNcG2CLff9Gl5--