Commit 20476c65 authored by Jim Harris's avatar Jim Harris Committed by Changpeng Liu
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I7c50ea0c16c6ced0a1aed59b225cb29d0f7b7345

Reviewed-on: https://review.gerrithub.io/c/441987


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent e430f6e0
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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);
	}