Permalink
Browse files

Allow usdt_provider_remove_probe to return an error status.

It's possible for removing probes to fail, either because there are none
or the probe can't be found.
  • Loading branch information...
1 parent 5e6ce57 commit 40f068ee657a32b8c8a60083eb61d4598ba5bbeb @chrisa committed Aug 20, 2012
Showing with 16 additions and 7 deletions.
  1. +13 −5 usdt.c
  2. +3 −2 usdt.h
View
18 usdt.c
@@ -17,7 +17,8 @@ char *usdt_errors[] = {
"failed to load DOF: %s",
"provider is already enabled",
"failed to unload DOF: %s",
- "probe named %s:%s:%s:%s already exists"
+ "probe named %s:%s:%s:%s already exists",
+ "failed to remove probe %s:%s:%s:%s"
};
usdt_provider_t *
@@ -91,13 +92,15 @@ usdt_provider_add_probe(usdt_provider_t *provider, usdt_probedef_t *probedef)
return (0);
}
-void
+int
usdt_provider_remove_probe(usdt_provider_t *provider, usdt_probedef_t *probedef)
{
usdt_probedef_t *pd, *prev_pd = NULL;
- if (provider->probedefs == NULL)
- return;
+ if (provider->probedefs == NULL) {
+ usdt_error(provider, USDT_ERROR_NOPROBES);
+ return (-1);
+ }
for (pd = provider->probedefs; (pd != NULL);
prev_pd = pd, pd = pd->next) {
@@ -111,9 +114,14 @@ usdt_provider_remove_probe(usdt_provider_t *provider, usdt_probedef_t *probedef)
prev_pd->next = pd->next;
/* free(probedef); */
- return;
+ return (0);
}
}
+
+ usdt_error(provider, USDT_ERROR_REMOVE_PROBE,
+ provider->name, provider->module,
+ probedef->function, probedef->name);
+ return (-1);
}
int
View
5 usdt.h
@@ -19,7 +19,8 @@ typedef enum usdt_error {
USDT_ERROR_LOADDOF,
USDT_ERROR_ALREADYENABLED,
USDT_ERROR_UNLOADDOF,
- USDT_ERROR_DUP_PROBE
+ USDT_ERROR_DUP_PROBE,
+ USDT_ERROR_REMOVE_PROBE
} usdt_error_t;
typedef struct usdt_probe {
@@ -53,7 +54,7 @@ typedef struct usdt_provider {
usdt_provider_t *usdt_create_provider(const char *name, const char *module);
int usdt_provider_add_probe(usdt_provider_t *provider, usdt_probedef_t *probedef);
-void usdt_provider_remove_probe(usdt_provider_t *provider, usdt_probedef_t *probedef);
+int usdt_provider_remove_probe(usdt_provider_t *provider, usdt_probedef_t *probedef);
int usdt_provider_enable(usdt_provider_t *provider);
int usdt_provider_disable(usdt_provider_t *provider);

0 comments on commit 40f068e

Please sign in to comment.