Skip to contentSkip to conversation

provider: only call discover for the provider implementations

PATCH In review Kris Van Hees 2 participants 2 messages Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 provider: only call discover for the provider implementations

Since the discover() functionality is provided by the implementation of a provider type rather than being specific to a provider, we only need to loop over dt_providers[]. The discover hooks themselves should take care of any newly discovered probes.

---
 libdtrace/dt_provider.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
libdtrace/dt_provider.c +5 -4
index e073e1f2..818390d2 100644
@@ -186,12 +186,13 @@ int
 dt_provider_discover(dtrace_hdl_t *dtp)
 {
 	int		prid = dtp->dt_probe_id;
-	dt_htab_next_t	*it = NULL;
-	dt_provider_t	*pvp;
+	int		i;
 
 	/* Discover new probes. */
-	while ((pvp = dt_htab_next(dtp->dt_provs, &it)) != NULL) {
-		if (pvp->impl->discover && pvp->impl->discover(dtp) < 0)
+	for (i = 0; dt_providers[i]; i++) {
+		const dt_provimpl_t	*pvops = dt_providers[i];
+
+		if (pvops->discover && pvops->discover(dtp) < 0)
 			return -1;        /* errno is already set */
 	}
 
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 37 lines · Kris Van Hees

Since the discover() functionality is provided by the implementation of a provider type rather than being specific to a provider, we only need to loop over dt_providers[]. The discover hooks themselves should take care of any newly discovered probes.

---
 libdtrace/dt_provider.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
libdtrace/dt_provider.c +5 -4
index e073e1f2..818390d2 100644
@@ -186,12 +186,13 @@ int
 dt_provider_discover(dtrace_hdl_t *dtp)
 {
 	int		prid = dtp->dt_probe_id;
-	dt_htab_next_t	*it = NULL;
-	dt_provider_t	*pvp;
+	int		i;
 
 	/* Discover new probes. */
-	while ((pvp = dt_htab_next(dtp->dt_provs, &it)) != NULL) {
-		if (pvp->impl->discover && pvp->impl->discover(dtp) < 0)
+	for (i = 0; dt_providers[i]; i++) {
+		const dt_provimpl_t	*pvops = dt_providers[i];
+
+		if (pvops->discover && pvops->discover(dtp) < 0)
 			return -1;        /* errno is already set */
 	}
 
Signature · 1 line
2.52.0