cvs commit: src/sys/sys protosw.h src/sys/kern uipc_domain.cuipc_socket2.c

Harti Brandt harti at freebsd.org
Tue Oct 19 22:55:28 PDT 2004


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


More information about the cvs-src mailing list