Skip to content

Commit d1ce203

Browse files
authored
Merge pull request #9818 from edgargabriel/topic/sharedfp_sm_open_cleanup
sharedfp_sm_file_open: minor code cleanup
2 parents 42cdf53 + 4af40ed commit d1ce203

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

ompi/mca/sharedfp/sm/sharedfp_sm_file_open.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* 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.
1313
* Copyright (c) 2013 Intel, Inc. All rights reserved.
1414
* Copyright (c) 2015-2018 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
@@ -59,7 +59,6 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
5959
struct mca_sharedfp_sm_data * sm_data = NULL;
6060
char * filename_basename;
6161
char * sm_filename;
62-
int sm_filename_length;
6362
struct mca_sharedfp_sm_offset * sm_offset_ptr;
6463
struct mca_sharedfp_sm_offset sm_offset;
6564
int sm_fd;
@@ -105,15 +104,6 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
105104
*/
106105
filename_basename = opal_basename((char*)filename);
107106
/* 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-
}
117107

118108
comm_cid = ompi_comm_get_cid(comm);
119109
if ( 0 == fh->f_rank ) {
@@ -130,7 +120,7 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
130120
return err;
131121
}
132122

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,
134124
filename_basename, comm_cid, int_pid);
135125
/* open shared memory file, initialize to 0, map into memory */
136126
sm_fd = open(sm_filename, O_RDWR | O_CREAT,

0 commit comments

Comments
 (0)