Date: Fri, 31 Mar 2006 19:54:11 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: "Bjoern A. Zeeb" <bz@FreeBSD.org> 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 Message-ID: <20060331192259.U1007@epsplex.bde.org> In-Reply-To: <20060330195236.G2181@maildrop.int.zabbadoz.net> References: <200603301857.k2UIv46o066136@repoman.freebsd.org> <20060330191338.Q2181@maildrop.int.zabbadoz.net> <200603302145.57382.max@love2party.net> <20060330195236.G2181@maildrop.int.zabbadoz.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060331192259.U1007>