From: Gabriel Corona Date: Fri, 20 Mar 2015 10:56:17 +0000 (+0100) Subject: [mc] Use MC_process_read_string() in MC_smx_process_get_name() (DRY) X-Git-Tag: v3_12~732^2~86 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0a4e408d9ec62f6184d591e92b365b2c0377196e [mc] Use MC_process_read_string() in MC_smx_process_get_name() (DRY) --- diff --git a/src/mc/mc_smx.c b/src/mc/mc_smx.c index bf647c7103..358e21be5f 100644 --- a/src/mc/mc_smx.c +++ b/src/mc/mc_smx.c @@ -221,31 +221,8 @@ const char* MC_smx_process_get_name(smx_process_t p) mc_smx_process_info_t info = MC_smx_process_get_info(p); if (!info->name) { - size_t size = 128; - char buffer[size]; - - size_t off = 0; - while (1) { - ssize_t n = pread(process->memory_file, buffer+off, size-off, (off_t)p->name + off); - if (n==-1) { - if (errno == EINTR) - continue; - else { - perror("MC_smx_process_get_name"); - xbt_die("Could not read memory"); - } - } - if (n==0) - return "?"; - void* end = memchr(buffer+off, '\0', n); - if (end) - break; - off += n; - if (off == size) - return "?"; - } xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap); - info->name = strdup(buffer); + info->name = MC_process_read_string(process, p->name); mmalloc_set_current_heap(heap); } return info->name;