[PATCH 2/2] trace-cmd: Validate input parameters of tracecmd_get_guest_cpumap() API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The API:
int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
			      unsigned long long trace_id,
			      const char **name,
			      int *vcpu_count, const int **cpu_pid)
is used to retrieve the host PID to guest VCPU mapping from a tracecmd input
handle, if such information is available in the trace.dat file for
the peer with the given trace_id. The input parameters name, vcpu_count and
cpu_pid are mandatory, they are used to return then requested mapping.
The API could be used also to check if such information is available, without
requesting it. Made those input parameters optional, so the API can be used
in this use case.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx>
---
 lib/trace-cmd/trace-input.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 6c358131..8651dac1 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3823,9 +3823,12 @@ int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
 	if (!guest)
 		return -1;
 
-	*name = guest->name;
-	*vcpu_count = guest->vcpu_count;
-	*cpu_pid = guest->cpu_pid;
+	if (name)
+		*name = guest->name;
+	if (vcpu_count)
+		*vcpu_count = guest->vcpu_count;
+	if (cpu_pid)
+		*cpu_pid = guest->cpu_pid;
 	return 0;
 }
 
-- 
2.25.1




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux