linked-list: Change return value of find_first() and signature of its callback

This avoids the unportable five pointer hack.
This commit is contained in:
Tobias Brunner
2017-05-26 13:56:44 +02:00
parent 8a2e4d4a8b
commit 2e4d110d1e
29 changed files with 526 additions and 398 deletions
+20 -18
View File
@@ -606,18 +606,14 @@ static void load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level);
/**
* Used to find a loaded feature
*/
static bool is_feature_loaded(provided_feature_t *item)
CALLBACK(is_feature_loaded, bool,
provided_feature_t *item, va_list args)
{
return item->loaded;
}
/**
* Used to find a loadable feature
*/
static bool is_feature_loadable(provided_feature_t *item)
CALLBACK(is_feature_loadable, bool,
provided_feature_t *item, va_list args)
{
return !item->loading && !item->loaded && !item->failed;
}
@@ -630,8 +626,7 @@ static bool loaded_feature_matches(registered_feature_t *a,
{
if (plugin_feature_matches(a->feature, b->feature))
{
return b->plugins->find_first(b->plugins, (void*)is_feature_loaded,
NULL) == SUCCESS;
return b->plugins->find_first(b->plugins, is_feature_loaded, NULL);
}
return FALSE;
}
@@ -644,8 +639,7 @@ static bool loadable_feature_equals(registered_feature_t *a,
{
if (plugin_feature_equals(a->feature, b->feature))
{
return b->plugins->find_first(b->plugins, (void*)is_feature_loadable,
NULL) == SUCCESS;
return b->plugins->find_first(b->plugins, is_feature_loadable, NULL);
}
return FALSE;
}
@@ -658,8 +652,7 @@ static bool loadable_feature_matches(registered_feature_t *a,
{
if (plugin_feature_matches(a->feature, b->feature))
{
return b->plugins->find_first(b->plugins, (void*)is_feature_loadable,
NULL) == SUCCESS;
return b->plugins->find_first(b->plugins, is_feature_loadable, NULL);
}
return FALSE;
}
@@ -1011,8 +1004,8 @@ static void purge_plugins(private_plugin_loader_t *this)
{ /* feature interface not supported */
continue;
}
if (entry->features->find_first(entry->features,
(void*)is_feature_loaded, NULL) != SUCCESS)
if (!entry->features->find_first(entry->features, is_feature_loaded,
NULL))
{
DBG2(DBG_LIB, "unloading plugin '%s' without loaded features",
entry->plugin->get_name(entry->plugin));
@@ -1062,6 +1055,15 @@ static bool find_plugin(char *path, char *name, char *buf, char **file)
return FALSE;
}
CALLBACK(find_plugin_cb, bool,
char *path, va_list args)
{
char *name, *buf, **file;
VA_ARGS_VGET(args, name, buf, file);
return find_plugin(path, name, buf, file);
}
/**
* Used to sort plugins by priority
*/
@@ -1244,8 +1246,8 @@ METHOD(plugin_loader_t, load_plugins, bool,
}
if (this->paths)
{
this->paths->find_first(this->paths, (void*)find_plugin, NULL,
token, buf, &file);
this->paths->find_first(this->paths, find_plugin_cb, NULL, token,
buf, &file);
}
if (!file)
{