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

Jeremy Allison jra at samba.org
Fri Apr 21 17:03:00 UTC 2017

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:
> > 
> > 
> > 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:

git grep static_init_nss

Which explains why I didn't find them :-(.

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

How did you notice the error ? Are there
any other places I need to know about
where declarations/definitions are constructed ?

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 !


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-modules-Change-XXX_init-interface-from-XXX_init-.patch
Type: text/x-diff
Size: 127630 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170421/1ec49c15/0001-lib-modules-Change-XXX_init-interface-from-XXX_init-.diff>

More information about the samba-technical mailing list