1
1

At least on NetBSD 5.0_STABLE with Libtool 2.2.6b, lt_dlerror() can

sometimes return NULL, so be sure to handle that case properly.

This commit was SVN r23503.
Этот коммит содержится в:
Jeff Squyres 2010-07-27 14:15:53 +00:00
родитель 245dc1a86d
Коммит 88b7923fc5

Просмотреть файл

@ -503,12 +503,18 @@ static int open_component(component_file_item_t *target_file,
component_handle = lt_dlopenext(target_file->filename);
#endif
if (NULL == component_handle) {
err = strdup(lt_dlerror());
/* Because libltdl erroneously says "file not found" for any type
of error -- which is especially misleading when the file is
actually there but cannot be opened for some other reason
(e.g., missing symbol) -- do some simple huersitics and if the
file [probably] does exist, print a slightly better error
/* Apparently lt_dlerror() sometimes returns NULL! */
const char *str = lt_dlerror();
if (NULL != str) {
err = strdup(str);
} else {
err = strdup("lt_dlerror() returned NULL!");
}
/* Because libltdl erroneously says "file not found" for any
type of error -- which is especially misleading when the file
is actually there but cannot be opened for some other reason
(e.g., missing symbol) -- do some simple huersitics and if
the file [probably] does exist, print a slightly better error
message. */
if (0 == strcmp("file not found", err) &&
(file_exists(target_file->filename, "lo") ||
@ -551,9 +557,14 @@ static int open_component(component_file_item_t *target_file,
component_struct = (mca_base_component_t*)lt_dlsym(component_handle, struct_name);
if (NULL == component_struct) {
/* Apparently lt_dlerror() sometimes returns NULL! */
const char *str = lt_dlerror();
if (NULL == str) {
str = "lt_dlerror() returned NULL!";
}
opal_output_verbose(vl, 0, "mca: base: component_find: \"%s\" does not appear to be a valid "
"%s MCA dynamic component (ignored): %s",
target_file->basename, target_file->type, lt_dlerror());
target_file->basename, target_file->type, str);
free(mitem);
free(struct_name);
lt_dlclose(component_handle);