X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-apiset.c;h=332d52daee562037c200f28693b93224c332891f;hb=29f544ba5fa53407575b549c1d3b0a4e2619af8f;hp=f837fae7680a8b98511536c8b97e434d4db98727;hpb=4c0f6ce66c66d39dc61ec661d88277c51d2fd9ae;p=src%2Fapp-framework-binder.git diff --git a/src/afb-apiset.c b/src/afb-apiset.c index f837fae7..332d52da 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*)) @@ -782,11 +788,11 @@ static int start_api(struct api_desc *api) api->status = EBUSY; rc = start_array_classes(&api->require.classes); if (rc < 0) - ERROR("Can start classes needed by api %s", api->name); + ERROR("Cannot start classes needed by api %s", api->name); else { rc = start_array_depends(&api->require.apis); if (rc < 0) - ERROR("Can start apis needed by api %s", api->name); + ERROR("Cannot start apis needed by api %s", api->name); else if (api->api.itf->service_start) { rc = api->api.itf->service_start(api->api.closure); if (rc < 0)