app/trace: simplify error messages when printing file name

Just have file_name point to shm_name when we're processing
shared memory.  This will be more helpful with the next
commit that adds more error messages.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I7c50ea0c16c6ced0a1aed59b225cb29d0f7b7345

Reviewed-on: https://review.gerrithub.io/c/441987
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Jim Harris 2019-01-24 17:41:38 -07:00 committed by Changpeng Liu
parent e430f6e068
commit 20476c6521

View File

@ -350,9 +350,10 @@ int main(int argc, char **argv)
snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", app_name, shm_pid);
}
fd = shm_open(shm_name, O_RDONLY, 0600);
file_name = shm_name;
}
if (fd < 0) {
fprintf(stderr, "Could not open %s.\n", file_name ? file_name : shm_name);
fprintf(stderr, "Could not open %s.\n", file_name);
usage();
exit(-1);
}
@ -360,7 +361,7 @@ int main(int argc, char **argv)
/* Map the header of trace file */
history_ptr = mmap(NULL, sizeof(*g_histories), PROT_READ, MAP_SHARED, fd, 0);
if (history_ptr == MAP_FAILED) {
fprintf(stderr, "Could not mmap %s.\n", file_name ? file_name : shm_name);
fprintf(stderr, "Could not mmap %s.\n", file_name);
usage();
exit(-1);
}
@ -383,7 +384,7 @@ int main(int argc, char **argv)
munmap(history_ptr, sizeof(*g_histories));
history_ptr = mmap(NULL, trace_histories_size, PROT_READ, MAP_SHARED, fd, 0);
if (history_ptr == MAP_FAILED) {
fprintf(stderr, "Could not mmap %s.\n", file_name ? file_name : shm_name);
fprintf(stderr, "Could not mmap %s.\n", file_name);
usage();
exit(-1);
}