From: Slavomir Kaslev <kaslevs@vmware.com>
To: linux-trace-devel@vger.kernel.org
Cc: rostedt@goodmis.org, ykaradzhov@vmware.com, tstoyanov@vmware.com
Subject: [PATCH v4 4/8] trace-cmd: Use unsigned int for trace-cmd client ports
Date: Wed, 16 Jan 2019 15:43:03 +0200 [thread overview]
Message-ID: <20190116134307.4185-5-kaslevs@vmware.com> (raw)
In-Reply-To: <20190116134307.4185-1-kaslevs@vmware.com>
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
By definition, communication ports used by trace-cmd clients
are 32 bit unsigned integers. These ports are generated randomly,
and in some implementations can overlap the signed integer range.
This patch converts all client ports in trace-cmd to be unsigned
32 bit integers.
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
---
include/trace-cmd/trace-cmd.h | 2 +-
tracecmd/trace-msg.c | 4 ++--
tracecmd/trace-record.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index ff4f0f7..8b43462 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -322,7 +322,7 @@ void tracecmd_msg_handle_close(struct tracecmd_msg_handle *msg_handle);
/* for clients */
int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
- int **client_ports);
+ unsigned int **client_ports);
int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
const char *buf, int size);
int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle);
diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
index edde582..529ae2a 100644
--- a/tracecmd/trace-msg.c
+++ b/tracecmd/trace-msg.c
@@ -386,12 +386,12 @@ static int tracecmd_msg_wait_for_msg(int fd, struct tracecmd_msg *msg)
}
int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
- int **client_ports)
+ unsigned int **client_ports)
{
struct tracecmd_msg send_msg;
struct tracecmd_msg recv_msg;
int fd = msg_handle->fd;
- int *ports;
+ unsigned int *ports;
int i, cpus;
int ret;
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index a8c3464..3034a4b 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -74,7 +74,7 @@ static int buffers;
static int clear_function_filters;
static char *host;
-static int *client_ports;
+static unsigned int *client_ports;
static int sfd;
/* Max size to let a per cpu file get */
@@ -2545,7 +2545,7 @@ static void connect_port(int cpu)
int s;
char buf[BUFSIZ];
- snprintf(buf, BUFSIZ, "%d", client_ports[cpu]);
+ snprintf(buf, BUFSIZ, "%u", client_ports[cpu]);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@@ -2755,7 +2755,7 @@ static void communicate_with_listener_v1(struct tracecmd_msg_handle *msg_handle)
/* No options */
write(msg_handle->fd, "0", 2);
- client_ports = malloc(sizeof(int) * local_cpu_count);
+ client_ports = malloc(local_cpu_count * sizeof(*client_ports));
if (!client_ports)
die("Failed to allocate client ports for %d cpus", local_cpu_count);
--
2.19.1
next prev parent reply other threads:[~2019-01-16 13:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 13:42 [PATCH v4 0/8] Add VM kernel tracing over vsock sockets Slavomir Kaslev
2019-01-16 13:43 ` [PATCH v4 1/8] trace-cmd: Minor refactoring Slavomir Kaslev
2019-01-16 13:43 ` [PATCH v4 2/8] trace-cmd: Detect if vsock sockets are available Slavomir Kaslev
2019-01-16 13:43 ` [PATCH v4 3/8] trace-cmd: Add tracecmd_create_recorder_virt function Slavomir Kaslev
2019-01-16 13:43 ` Slavomir Kaslev [this message]
2019-01-16 13:43 ` [PATCH v4 5/8] trace-cmd: Add TRACE_REQ and TRACE_RESP messages Slavomir Kaslev
2019-01-16 14:19 ` Steven Rostedt
2019-01-16 13:43 ` [PATCH v4 6/8] trace-cmd: Add buffer instance flags for tracing in guest and agent context Slavomir Kaslev
2019-01-16 13:43 ` [PATCH v4 7/8] trace-cmd: Add VM kernel tracing over vsock sockets transport Slavomir Kaslev
2019-01-16 13:43 ` [PATCH v4 8/8] trace-cmd: Use splice(2) for vsock sockets if available Slavomir Kaslev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190116134307.4185-5-kaslevs@vmware.com \
--to=kaslevs@vmware.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tstoyanov@vmware.com \
--cc=ykaradzhov@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).