Per report from Kamil Dudka. * src/exclist.c (hg_initfn): Make the initialization of data pointer here rather than expecting caller will do it. (vcs_ignore_file): Fix the initfn prototype. (info_attach_exclist): Let the initfn do the initialization. --- src/exclist.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/exclist.c b/src/exclist.c index c24a00c..c788a7d 100644 --- a/src/exclist.c +++ b/src/exclist.c @@ -30,7 +30,7 @@ struct vcs_ignore_file char const *filename; int flags; add_fn addfn; - void *(*initfn) (void *); + void (*initfn) (void *); void *data; }; @@ -101,7 +101,7 @@ info_attach_exclist (struct tar_stat_info *dir) vcsfile = get_vcs_ignore_file (file->name); if (vcsfile->initfn) - vcsfile->data = vcsfile->initfn (vcsfile->data); + vcsfile->initfn (&vcsfile->data); if (add_exclude_fp (vcsfile->addfn, ex, fp, EXCLUDE_WILDCARDS|EXCLUDE_ANCHORED, '\n', @@ -247,17 +247,17 @@ bzr_addfn (struct exclude *ex, char const *pattern, int options, void *data) add_exclude (ex, pattern, options); } -static void * +static void hg_initfn (void *data) { - int *hgopt; static int hg_options; - if (!data) - hgopt = &hg_options; + /* make data pointer point to static hg_options */ + int **hgopt = data; + if (!*hgopt) + *hgopt = &hg_options; - *hgopt = EXCLUDE_REGEX; - return hgopt; + hg_options = EXCLUDE_REGEX; } static void -- 2.5.0