Skip to content

Commit 35ae7e3

Browse files
committed
Merge pull request #1639 from jjhursey/topic/dl-open-null-fname
dl/dlopen/libltdl: Allow opal_dl_open to take a NULL filename.
2 parents 8ec1891 + 677178f commit 35ae7e3

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

opal/mca/dl/dlopen/dl_dlopen_module.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
44
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
55
* reserved.
6+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
67
* $COPYRIGHT$
78
*
89
* Additional copyrights may follow
@@ -32,7 +33,6 @@
3233
static void do_dlopen(const char *fname, int flags,
3334
void **handle, char **err_msg)
3435
{
35-
assert(fname);
3636
assert(handle);
3737

3838
*handle = dlopen(fname, flags);
@@ -50,7 +50,6 @@ static void do_dlopen(const char *fname, int flags,
5050
static int dlopen_open(const char *fname, bool use_ext, bool private_namespace,
5151
opal_dl_handle_t **handle, char **err_msg)
5252
{
53-
assert(fname);
5453
assert(handle);
5554

5655
*handle = NULL;
@@ -66,7 +65,7 @@ static int dlopen_open(const char *fname, bool use_ext, bool private_namespace,
6665
/* If the caller wants to use filename extensions, loop through
6766
them */
6867
void *local_handle = NULL;
69-
if (use_ext) {
68+
if (use_ext && NULL != fname) {
7069
int i;
7170
char *ext;
7271

@@ -109,7 +108,12 @@ static int dlopen_open(const char *fname, bool use_ext, bool private_namespace,
109108
(*handle)->dlopen_handle = local_handle;
110109

111110
#if OPAL_ENABLE_DEBUG
112-
(*handle)->filename = strdup(fname);
111+
if( NULL != fname ) {
112+
(*handle)->filename = strdup(fname);
113+
}
114+
else {
115+
(*handle)->filename = strdup("(null)");
116+
}
113117
#endif
114118
}
115119
return (NULL != local_handle) ? OPAL_SUCCESS : OPAL_ERROR;

opal/mca/dl/libltdl/dl_libltdl_module.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
3+
* Copyright (c) 2016 IBM Corporation. All rights reserved.
34
* $COPYRIGHT$
45
*
56
* Additional copyrights may follow
@@ -18,7 +19,6 @@
1819
static int libltdl_open(const char *fname, bool use_ext, bool private_namespace,
1920
opal_dl_handle_t **handle, char **err_msg)
2021
{
21-
assert(fname);
2222
assert(handle);
2323

2424
*handle = NULL;
@@ -53,7 +53,12 @@ static int libltdl_open(const char *fname, bool use_ext, bool private_namespace,
5353
(*handle)->ltdl_handle = local_handle;
5454

5555
#if OPAL_ENABLE_DEBUG
56-
(*handle)->filename = strdup(fname);
56+
if( NULL != fname ) {
57+
(*handle)->filename = strdup(fname);
58+
}
59+
else {
60+
(*handle)->filename = strdup("(null)");
61+
}
5762
#endif
5863

5964
return OPAL_SUCCESS;

0 commit comments

Comments
 (0)