Questions about iter check in profile_iterator()

Will Fiveash will.fiveash at
Wed Jan 14 17:37:18 EST 2015

On Wed, Jan 14, 2015 at 03:45:01PM -0600, Will Fiveash wrote:
> On Mon, Jan 12, 2015 at 10:40:39PM -0500, Greg Hudson wrote:
> > 
> > On 01/12/2015 08:13 PM, Will Fiveash wrote:
> > > So in the profile_iterator call to profile_node_iterator() the
> > > &iter->idata arg is iter_p for profile_node_iterator?  Seems odd to me.
> > 
> > I don't see what is odd about that.  iter->idata holds the node iterator
> > state.
> Eh, looking at the code more I see what's going on so nevermind.

And looking more I think that in the public header there should be:

struct prof_iter;
typedef struct prof_iter *prof_iter;

and the profile_iterator declaration:

profile_iterator(void **iter_p,...

should instead be:

profile_iterator(prof_iter *iter_p,...

  struct profile_iterator *iter = (struct profile_iterator *) *iter_p;

etc...  This would allow the compiler type checking to catch caller
errors like:

void*      iterator = NULL;
profile_iterator (iterator, &realm_name, &dummy_value);

which should be:

profile_iterator (&iterator, &realm_name, &dummy_value);

Those type of calling errors can currently slip by the compiler.

Will Fiveash
Oracle Solaris Software Engineer

More information about the krbdev mailing list