[PATCH] Change module interface to pass in a TALLOC_CTX pointer.

Ralph Böhme slow at samba.org
Fri Apr 21 17:08:15 UTC 2017


On Fri, Apr 21, 2017 at 10:03:00AM -0700, Jeremy Allison wrote:
> On Fri, Apr 21, 2017 at 02:29:23PM +0200, Ralph Böhme wrote:
> > Hi Jeremy,
> > 
> > On Fri, Apr 21, 2017 at 03:01:41AM +0000, Jeremy Allison wrote:
> > > Currently the initialization function of all our modules are called with a
> > > function signature of:
> > > 
> > > NTSTATUS XXX_init(void)
> > > 
> > > The following patch changes this to be:
> > > 
> > > NTSTATUS XXX_init(TALLOC_CTX *ctx)
> > > 
> > > instead. The patch (for 4.7.x naturally) merely changes
> > > the definition of the initialization functions and their
> > > callers, and implements *no* logic changes (all of the changed
> > > callers in this patch pass NULL in as the new TALLOC_CTX *ctx
> > > and the modules ignore it).
> > 
> > Nice!
> > 
> > One thing: you missed the static initializers and declarations, eg for the VFS:
> > 
> > vfs_init_custom() uses "static_init_vfs;" which expands to
> > 
> >   #define static_init_vfs { vfs_default_init();  vfs_posixacl_init();  vfs_dfs_samba4_init(); }
> > 
> > But the vfs init functions now take a TALLOC_CTX arg, eg
> > 
> >    NTSTATUS vfs_default_init(TALLOC_CTX *ctx)
> > 
> > The compiler doesn't complain, because the static_decl_vfs contains the same
> > wrong function signatures:
> > 
> >   #define static_decl_vfs extern NTSTATUS vfs_default_init(void); extern NTSTATUS vfs_posixacl_init(void); extern NTSTATUS vfs_dfs_samba4_init(void);
> > 
> > Attached patch should fix this. Fixup your commit with mine if happy.
> 
> Thanks for that Ralph ! Much appreciated.
> 
> Minor waf complaint....
> 
> If you do:
> 
> git grep static_decl_vfs
> 
> You can't find the definition of that *anywhere*,
> because it's a magic waf construct made out of
> unicorns, rainbows and python. Same for:

well, I'm by no means a waf fan, but this can happen with other buildsystems as
well. :)

> 
> git grep static_init_nss
> 
> Which explains why I didn't find them :-(.

hehe

> I *hate* magic declarations/definitions, or
> anything you can't 'git grep' for and find.

I use cscope, that finds it. ctags should look inside bin as well.

> How did you notice the error ?

Because I knew it was there. :)

> Are there any other places I need to know about
> where declarations/definitions are constructed ?

No. The only place (I know of :)))) ) is source3/wscript and I already fixed it
for you.

> Once this goes in I should be able to safely
> remove all talloc_autofree_context() calls out
> of everywhere except ldb, which has it's own
> custom module init interface that takes a
> 'const char *version' parameter. I plan to
> look at that later.
> 
> Here is your patch squashed with mine and your
> Signed-off-by: added.
> 
> Please push if happy !

will do.

-slow



More information about the samba-technical mailing list