[2250] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

Re: Function pointers with krb5_{calculate,verify}_checksum

daemon@ATHENA.MIT.EDU (Ken Raeburn)
Wed Feb 19 22:57:17 1997

To: Ken Hornstein <kenh@cmf.nrl.navy.mil>
Cc: krbdev@MIT.EDU
From: Ken Raeburn <raeburn@cygnus.com>
Date: 19 Feb 1997 17:12:52 -0500
In-Reply-To: Ken Hornstein's message of Wed, 19 Feb 1997 09:50:49 -0500

Ken Hornstein <kenh@cmf.nrl.navy.mil> writes:

> However, when trying to get Kerberos working on our HP/Convex Exemplar, I
> ran across what appears to be a problem with the way the checksum macros
> are declared.  I kept getting bus errors anytime checksums were calculated.
...
> So this ends up being:
> 
> *krb5_cksumarray[ctype]->sum_verf_func ?
> 	*(*krb5_cksumarray[ctype]->sum_verf_func)(...) : (abort(), 1);
> 
> Now, color me stupid, but that sure _looks_ like one too many dereferences
> to me.

ANSI C rules specify that function "values" are automatically
converted to the function's address, except in the function-call
context.  And a call done with a function pointer does the right
thing.  I'm a bit fuzzy on those parts of the rules, but I think
that's roughly right.

So "*f", where f is a function pointer, has the dereference
automatically undone, sort of.  Which means you get a function pointer
again.  Repeat as needed.  This code has two perfectly normal (if
somewhat odd-looking) function calls:

	extern int (*f) ();
	void x () { (***********f) (); f (); }

> Removing the * fixes the problem and makes Kerberos clients work.
> 
> Am I way off base here?  The thing that puzzles me is, if this is a problem,
> how come it doesn't show up on other architectures?

Because the other compilers implement this correctly.

home help back first fref pref prev next nref lref last post