From owner-cvs-src@FreeBSD.ORG Fri Mar 31 08:54:17 2006 Return-Path: X-Original-To: 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 6D35216A41F; Fri, 31 Mar 2006 08:54:17 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D23B43D5D; Fri, 31 Mar 2006 08:54:16 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87]) by mailout1.pacific.net.au (Postfix) with ESMTP id 87D72527F73; Fri, 31 Mar 2006 19:54:14 +1100 (EST) Received: from epsplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy2.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k2V8sCAE029687; Fri, 31 Mar 2006 19:54:13 +1100 Date: Fri, 31 Mar 2006 19:54:11 +1100 (EST) From: Bruce Evans X-X-Sender: bde@epsplex.bde.org To: "Bjoern A. Zeeb" In-Reply-To: <20060330195236.G2181@maildrop.int.zabbadoz.net> Message-ID: <20060331192259.U1007@epsplex.bde.org> References: <200603301857.k2UIv46o066136@repoman.freebsd.org> <20060330191338.Q2181@maildrop.int.zabbadoz.net> <200603302145.57382.max@love2party.net> <20060330195236.G2181@maildrop.int.zabbadoz.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/netipsec xform.h xform_ipip.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2006 08:54:17 -0000 On Thu, 30 Mar 2006, Bjoern A. Zeeb wrote: > On Thu, 30 Mar 2006, Max Laier wrote: > >> On Thursday 30 March 2006 21:17, Bjoern A. Zeeb wrote: >>> On Thu, 30 Mar 2006, Bjoern A. Zeeb wrote: >>>> bz 2006-03-30 18:57:04 UTC >>>> >>>> FreeBSD src repository >>>> >>>> Modified files: >>>> sys/netipsec xform.h xform_ipip.c >>>> Log: >>>> Fix more stack corruptions on amd64. >>> ... >>> If anybody knows an easy way to find all casted function pointers >>> that are using varargs let me know ;-) Change gcc to optionally warn about all bogus casts. This would include all casts of function pointers (it is just an implementation detail that casts of varargs functions are more likely to cause problems at runtime). This would be easy, but filtering out all the warnings about non-broken casdes wouldn't be. >> Shouldn't we be able to teach Coverity? It certainly has the information >> somewhere. > > next question: why does the compiler not complain? Because any function pointer type may be converted to any function pointer type (and back) in much the same way that any object pointer type may be converted to "void *" (and back). It is only an error to use a function pointer to call a function whose type is not compatible with the pointed-to type. If the pointed-to type is different from the function type, then it is necessary to convert the pointer to exactly the function type before calling the function in the same way that it is (more obviously) necessary to convert "void *" back to the almost exactly the original object pointer type. (If a function pointer is not converted back exactly, then the behaviour is undefined, but for object pointers some cases (mainly converting to "u_char *" and indirection through this) are defined and some cases (mainly ones where things end up sufficiently aligned) are implementation-defined.) Bruce