diff options
Diffstat (limited to 'tools/lib/traceevent/event-plugin.c')
-rw-r--r-- | tools/lib/traceevent/event-plugin.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index a16756ae3526..d542cb60ca1a 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c | |||
@@ -120,12 +120,12 @@ char **traceevent_plugin_list_options(void) | |||
120 | for (op = reg->options; op->name; op++) { | 120 | for (op = reg->options; op->name; op++) { |
121 | char *alias = op->plugin_alias ? op->plugin_alias : op->file; | 121 | char *alias = op->plugin_alias ? op->plugin_alias : op->file; |
122 | char **temp = list; | 122 | char **temp = list; |
123 | int ret; | ||
123 | 124 | ||
124 | name = malloc(strlen(op->name) + strlen(alias) + 2); | 125 | ret = asprintf(&name, "%s:%s", alias, op->name); |
125 | if (!name) | 126 | if (ret < 0) |
126 | goto err; | 127 | goto err; |
127 | 128 | ||
128 | sprintf(name, "%s:%s", alias, op->name); | ||
129 | list = realloc(list, count + 2); | 129 | list = realloc(list, count + 2); |
130 | if (!list) { | 130 | if (!list) { |
131 | list = temp; | 131 | list = temp; |
@@ -290,17 +290,14 @@ load_plugin(struct pevent *pevent, const char *path, | |||
290 | const char *alias; | 290 | const char *alias; |
291 | char *plugin; | 291 | char *plugin; |
292 | void *handle; | 292 | void *handle; |
293 | int ret; | ||
293 | 294 | ||
294 | plugin = malloc(strlen(path) + strlen(file) + 2); | 295 | ret = asprintf(&plugin, "%s/%s", path, file); |
295 | if (!plugin) { | 296 | if (ret < 0) { |
296 | warning("could not allocate plugin memory\n"); | 297 | warning("could not allocate plugin memory\n"); |
297 | return; | 298 | return; |
298 | } | 299 | } |
299 | 300 | ||
300 | strcpy(plugin, path); | ||
301 | strcat(plugin, "/"); | ||
302 | strcat(plugin, file); | ||
303 | |||
304 | handle = dlopen(plugin, RTLD_NOW | RTLD_GLOBAL); | 301 | handle = dlopen(plugin, RTLD_NOW | RTLD_GLOBAL); |
305 | if (!handle) { | 302 | if (!handle) { |
306 | warning("could not load plugin '%s'\n%s\n", | 303 | warning("could not load plugin '%s'\n%s\n", |
@@ -391,6 +388,7 @@ load_plugins(struct pevent *pevent, const char *suffix, | |||
391 | char *home; | 388 | char *home; |
392 | char *path; | 389 | char *path; |
393 | char *envdir; | 390 | char *envdir; |
391 | int ret; | ||
394 | 392 | ||
395 | if (pevent->flags & PEVENT_DISABLE_PLUGINS) | 393 | if (pevent->flags & PEVENT_DISABLE_PLUGINS) |
396 | return; | 394 | return; |
@@ -421,16 +419,12 @@ load_plugins(struct pevent *pevent, const char *suffix, | |||
421 | if (!home) | 419 | if (!home) |
422 | return; | 420 | return; |
423 | 421 | ||
424 | path = malloc(strlen(home) + strlen(LOCAL_PLUGIN_DIR) + 2); | 422 | ret = asprintf(&path, "%s/%s", home, LOCAL_PLUGIN_DIR); |
425 | if (!path) { | 423 | if (ret < 0) { |
426 | warning("could not allocate plugin memory\n"); | 424 | warning("could not allocate plugin memory\n"); |
427 | return; | 425 | return; |
428 | } | 426 | } |
429 | 427 | ||
430 | strcpy(path, home); | ||
431 | strcat(path, "/"); | ||
432 | strcat(path, LOCAL_PLUGIN_DIR); | ||
433 | |||
434 | load_plugins_dir(pevent, suffix, path, load_plugin, data); | 428 | load_plugins_dir(pevent, suffix, path, load_plugin, data); |
435 | 429 | ||
436 | free(path); | 430 | free(path); |