X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-apiset.c;h=6229b3710a3bb90b03333e71b1ba95595bc3cea1;hb=c4835ee2a1b46069e5addf6f8b023c2e66e3665b;hp=994a9c7eea47196ca31bce1c445dee6bfd536d01;hpb=bebb8fa967f3b71b609119b293d2869d56036586;p=src%2Fapp-framework-binder.git diff --git a/src/afb-apiset.c b/src/afb-apiset.c index 994a9c7e..6229b371 100644 --- a/src/afb-apiset.c +++ b/src/afb-apiset.c @@ -427,17 +427,23 @@ struct afb_apiset *afb_apiset_subset_get(struct afb_apiset *set) * Set the subset of the set * @param set the api set * @param subset the subset to set + * + * @return 0 in case of success or -1 if it had created a loop */ -void afb_apiset_subset_set(struct afb_apiset *set, struct afb_apiset *subset) +int afb_apiset_subset_set(struct afb_apiset *set, struct afb_apiset *subset) { struct afb_apiset *tmp; - if (subset == set) { - /* avoid infinite loop */ - subset = NULL; - } + + /* avoid infinite loop */ + for (tmp = subset ; tmp ; tmp = tmp->subset) + if (tmp == set) + return -1; + tmp = set->subset; set->subset = afb_apiset_addref(subset); afb_apiset_unref(tmp); + + return 0; } void afb_apiset_onlack_set(struct afb_apiset *set, int (*callback)(void*, struct afb_apiset*, const char*), void *closure, void (*cleanup)(void*)) @@ -495,7 +501,8 @@ int afb_apiset_add(struct afb_apiset *set, const char *name, struct afb_api_item desc->next = all_apis; all_apis = desc; - INFO("API %s added", name); + if (afb_api_is_public(name)) + INFO("API %s added", name); return 0;