X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fmodule.c;h=a1826b91430e2255396d4f6a9f82278bc8c0772f;hb=dbd243b1b5f764129ae8bcf95432df750bec4a8b;hp=c4d3d6b07405c037a444cd11058e42cea2de876a;hpb=d8f124de0295aea546b6debf5945bfeea2bbeb2a;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/module.c b/ltt/branches/poly/lttv/lttv/module.c index c4d3d6b0..a1826b91 100644 --- a/ltt/branches/poly/lttv/lttv/module.c +++ b/ltt/branches/poly/lttv/lttv/module.c @@ -70,7 +70,7 @@ static GQuark lttv_module_error; static void init(); -static finish_destroy(); +static void finish_destroy(); static void module_release(LttvModule *m); @@ -129,16 +129,17 @@ static void library_remove(LttvLibrary *l) LttvModule *m; GPtrArray *modules; - + GPtrArray **modules_ptr = &modules; /* for strict aliasing */ guint i; char *key; + char **key_ptr = &key; /* for strict aliasing */ for(i = 0 ; i < l->modules->len ; i++) { m = (LttvModule *)(l->modules->pdata[i]); g_hash_table_lookup_extended(modules_by_name, m->info.name, - (gpointer *)&key, (gpointer *)&modules); + (gpointer *)key_ptr, (gpointer *)modules_ptr); g_assert(modules != NULL); g_ptr_array_remove(modules, m); if(modules->len == 0) { @@ -162,11 +163,12 @@ static void library_remove(LttvLibrary *l) static LttvLibrary *library_load(char *name, GError **error) { - GModule *gm; + GModule *gm = NULL; int i, nb; - char *path, *pathname; + /* path is always initialized, checked */ + char *path = NULL, *pathname; LttvLibrary *l; @@ -189,7 +191,7 @@ static LttvLibrary *library_load(char *name, GError **error) module_chain = NULL; module_next = &module_chain; gm = g_module_open(pathname,0); - g_free(pathname); + g_free(pathname); if(gm != NULL) break; @@ -226,15 +228,15 @@ static LttvLibrary *library_load(char *name, GError **error) LttvLibrary *lttv_library_load(char *name, GError **error) { - LttvLibrary *l = library_load(name, error); - l->info.load_count++; + LttvLibrary *l = library_load(name, error); + if(l != NULL) l->info.load_count++; return l; } static void library_unload(LttvLibrary *l) { - guint i, len; + guint i; GModule *gm; @@ -277,7 +279,9 @@ static void library_unload(LttvLibrary *l) void lttv_library_unload(LttvLibrary *l) { - l->info.load_count--; + /* In the case where we wait for a module to release, the load count is 0 + * and should not be decremented. */ + if(l->info.load_count != 0) l->info.load_count--; library_unload(l); } @@ -459,14 +463,14 @@ LttvLibrary *lttv_library_get(unsigned i) } -void lttv_library_path_add(char *name) +void lttv_library_path_add(const char *name) { g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Add library path %s", name); g_ptr_array_add(library_paths,(char*)g_strdup(name)); } -void lttv_library_path_remove(char *name) +void lttv_library_path_remove(const char *name) { guint i; @@ -520,7 +524,7 @@ static void init() } -static finish_destroy() +static void finish_destroy() { guint i;