pkg: use typename enforcement on pkg_traverse()

pull/29/head
William Pitcock 2012-05-11 19:56:38 -05:00
parent bb41d143cc
commit acf2ee260b
2 changed files with 11 additions and 9 deletions

16
pkg.c
View File

@ -583,7 +583,7 @@ pkg_report_graph_error(pkg_t *pkg, pkg_dependency_t *node, unsigned int eflags)
static inline unsigned int static inline unsigned int
pkg_walk_list(pkg_dependency_t *deplist, pkg_walk_list(pkg_dependency_t *deplist,
void (*pkg_traverse_func)(pkg_t *package, void *data), pkg_traverse_func_t func,
void *data, void *data,
int depth, int depth,
unsigned int flags) unsigned int flags)
@ -602,7 +602,7 @@ pkg_walk_list(pkg_dependency_t *deplist,
if (eflags != PKG_ERRF_OK) if (eflags != PKG_ERRF_OK)
return pkg_report_graph_error(pkgdep, node, eflags); return pkg_report_graph_error(pkgdep, node, eflags);
pkg_traverse(pkgdep, pkg_traverse_func, data, depth - 1, flags); pkg_traverse(pkgdep, func, data, depth - 1, flags);
pkg_free(pkgdep); pkg_free(pkgdep);
} }
@ -611,13 +611,13 @@ pkg_walk_list(pkg_dependency_t *deplist,
} }
/* /*
* pkg_traverse(root, pkg_traverse_func, data, maxdepth) * pkg_traverse(root, func, data, maxdepth, flags)
* *
* walk the dependency graph up to maxdepth levels. -1 means infinite recursion. * walk the dependency graph up to maxdepth levels. -1 means infinite recursion.
*/ */
unsigned int unsigned int
pkg_traverse(pkg_t *root, pkg_traverse(pkg_t *root,
void (*pkg_traverse_func)(pkg_t *package, void *data), pkg_traverse_func_t func,
void *data, void *data,
int maxdepth, int maxdepth,
unsigned int flags) unsigned int flags)
@ -628,13 +628,13 @@ pkg_traverse(pkg_t *root,
if (maxdepth == 0) if (maxdepth == 0)
return eflags; return eflags;
eflags = pkg_walk_list(root->requires, pkg_traverse_func, data, maxdepth, rflags); eflags = pkg_walk_list(root->requires, func, data, maxdepth, rflags);
if (eflags != PKG_ERRF_OK) if (eflags != PKG_ERRF_OK)
return eflags; return eflags;
if (flags & PKGF_SEARCH_PRIVATE) if (flags & PKGF_SEARCH_PRIVATE)
{ {
eflags = pkg_walk_list(root->requires_private, pkg_traverse_func, data, maxdepth, rflags); eflags = pkg_walk_list(root->requires_private, func, data, maxdepth, rflags);
if (eflags != PKG_ERRF_OK) if (eflags != PKG_ERRF_OK)
return eflags; return eflags;
} }
@ -642,8 +642,8 @@ pkg_traverse(pkg_t *root,
if ((root->flags & PKG_PROPF_VIRTUAL) && (flags & PKGF_SKIP_ROOT_VIRTUAL)) if ((root->flags & PKG_PROPF_VIRTUAL) && (flags & PKGF_SKIP_ROOT_VIRTUAL))
return eflags; return eflags;
if (pkg_traverse_func != NULL) if (func != NULL)
pkg_traverse_func(root, data); func(root, data);
return eflags; return eflags;
} }

4
pkg.h
View File

@ -121,10 +121,12 @@ struct pkg_ {
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 #define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2
typedef void (*pkg_traverse_func_t)(pkg_t *pkg, void *data);
/* pkg.c */ /* pkg.c */
void pkg_free(pkg_t *pkg); void pkg_free(pkg_t *pkg);
pkg_t *pkg_find(const char *name, unsigned int flags); pkg_t *pkg_find(const char *name, unsigned int flags);
unsigned int pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags); unsigned int pkg_traverse(pkg_t *root, pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags); unsigned int pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);
int pkg_compare_version(const char *a, const char *b); int pkg_compare_version(const char *a, const char *b);
pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); pkg_t *pkg_verify_dependency(pkg_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);