From owner-cvs-src@FreeBSD.ORG  Wed Oct 20 05:55:28 2004
Return-Path: <owner-cvs-src@FreeBSD.ORG>
Delivered-To: cvs-src@freebsd.org
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 61FC816A4CE; Wed, 20 Oct 2004 05:55:28 +0000 (GMT)
Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com
	[129.247.16.33])	by mx1.FreeBSD.org (Postfix) with ESMTP
	id 0587143D3F; Wed, 20 Oct 2004 05:55:27 +0000 (GMT)
	(envelope-from harti@freebsd.org)
Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1])
	i9K5tOU219024;	Wed, 20 Oct 2004 07:55:24 +0200
Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3])
	i9K5tNI59562;	Wed, 20 Oct 2004 07:55:23 +0200
Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178])
	by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i9K5tRe18160;
	Wed, 20 Oct 2004 07:55:28 +0200 (MET DST)
Date: Wed, 20 Oct 2004 07:55:32 +0200 (CEST)
From: Harti Brandt <harti@freebsd.org>
X-X-Sender: brandt@beagle.kn.op.dlr.de
To: Andre Oppermann <andre@freebsd.org>
In-Reply-To: <41758B35.D5340AEA@freebsd.org>
Message-ID: <20041020074747.B21281@beagle.kn.op.dlr.de>
References: <200410191513.i9JFDUbf072176@repoman.freebsd.org>
 <417532A2.9000901@errno.com> <41753522.1E39FEAE@freebsd.org>
 <200410192329.46723.max@love2party.net> <41758B35.D5340AEA@freebsd.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
cc: Max Laier <max@love2party.net>
cc: src-committers@freebsd.org
cc: cvs-all@freebsd.org
cc: cvs-src@freebsd.org
cc: Sam Leffler <sam@errno.com>
Subject: Re: cvs commit: src/sys/sys protosw.h src/sys/kern  
 uipc_domain.cuipc_socket2.c
X-BeenThere: cvs-src@freebsd.org
X-Mailman-Version: 2.1.1
Precedence: list
Reply-To: Harti Brandt <harti@freebsd.org>
List-Id: CVS commit messages for the src tree <cvs-src.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/cvs-src>,
	<mailto:cvs-src-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/cvs-src>
List-Post: <mailto:cvs-src@freebsd.org>
List-Help: <mailto:cvs-src-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/cvs-src>,
	<mailto:cvs-src-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 20 Oct 2004 05:55:28 -0000

On Tue, 19 Oct 2004, Andre Oppermann wrote:

AO>Max Laier wrote:
AO>> example, in ip_icmp.c line 457 ff we have:
AO>> 
AO>>                ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput;
AO>>                if (ctlfunc)
AO>>                         (*ctlfunc)(code, (struct sockaddr *)&icmpsrc,
AO>>                                    (void *)&icp->icmp_ip);
AO>
AO>Ok, this one is easy to fix.  I'll audit the code for any other of these
AO>abuses.

Actually it is not easy to fix. Even if you don't introduce a temporary
variable the compiler can and probably will still use a temporary copy of the
function pointer.

AO>The point of the protocol arrays is precisely to have them as the only
AO>and sole place where such information is stored.  Any code that copies
AO>any part of it to its own private structures is horribly broken by design
AO>and must be fixed anyway!  (BTW: I'm not aware of any code within netinet/*
AO>that does this.)

You cannot prevent the compiler from makeing temporary copies.

harti