9
9
* University of Stuttgart. All rights reserved.
10
10
* Copyright (c) 2004-2005 The Regents of the University of California.
11
11
* All rights reserved.
12
- * Copyright (c) 2013-2018 University of Houston. All rights reserved.
12
+ * Copyright (c) 2013-2021 University of Houston. All rights reserved.
13
13
* Copyright (c) 2013 Intel, Inc. All rights reserved.
14
14
* Copyright (c) 2015-2018 Research Organization for Information Science
15
15
* and Technology (RIST). All rights reserved.
@@ -59,7 +59,6 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
59
59
struct mca_sharedfp_sm_data * sm_data = NULL ;
60
60
char * filename_basename ;
61
61
char * sm_filename ;
62
- int sm_filename_length ;
63
62
struct mca_sharedfp_sm_offset * sm_offset_ptr ;
64
63
struct mca_sharedfp_sm_offset sm_offset ;
65
64
int sm_fd ;
@@ -105,15 +104,6 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
105
104
*/
106
105
filename_basename = opal_basename ((char * )filename );
107
106
/* format is "%s/%s_cid-%d-%d.sm", see below */
108
- sm_filename_length = strlen (ompi_process_info .job_session_dir ) + 1 + strlen (filename_basename ) + 5 + (3 * sizeof (uint32_t )+1 ) + 4 ;
109
- sm_filename = (char * ) malloc ( sizeof (char ) * sm_filename_length );
110
- if (NULL == sm_filename ) {
111
- opal_output (0 , "mca_sharedfp_sm_file_open: Error, unable to malloc sm_filename\n" );
112
- free (filename_basename );
113
- free (sm_data );
114
- free (sh );
115
- return OMPI_ERR_OUT_OF_RESOURCE ;
116
- }
117
107
118
108
comm_cid = ompi_comm_get_cid (comm );
119
109
if ( 0 == fh -> f_rank ) {
@@ -130,7 +120,7 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
130
120
return err ;
131
121
}
132
122
133
- snprintf ( sm_filename , sm_filename_length , "%s/%s_cid-%d-%d.sm" , ompi_process_info .job_session_dir ,
123
+ asprintf ( & sm_filename , "%s/%s_cid-%d-%d.sm" , ompi_process_info .job_session_dir ,
134
124
filename_basename , comm_cid , int_pid );
135
125
/* open shared memory file, initialize to 0, map into memory */
136
126
sm_fd = open (sm_filename , O_RDWR | O_CREAT ,
0 commit comments