cvs commit: src/sys/netipsec xform.h xform_ipip.c

Bruce Evans bde at zeta.org.au
Fri Mar 31 08:54:17 UTC 2006


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


More information about the cvs-src mailing list