All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Slavomir Kaslev <kaslevs@vmware.com>
Cc: linux-trace-devel@vger.kernel.org, slavomir.kaslev@gmail.com
Subject: Re: [PATCH 3/3] trace-cmd: Add msg_buf_len() function
Date: Fri, 15 Mar 2019 15:08:36 -0400	[thread overview]
Message-ID: <20190315150836.7e2bc4f3@gandalf.local.home> (raw)
In-Reply-To: <20190315153326.5602-4-kaslevs@vmware.com>

On Fri, 15 Mar 2019 17:33:26 +0200
Slavomir Kaslev <kaslevs@vmware.com> wrote:

> Factor out common code computing message buffer length in a function.
> 
> No changes in behavior intended.
> 
> Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
> ---
>  tracecmd/trace-msg.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
> index 48f1eac..a91b211 100644
> --- a/tracecmd/trace-msg.c
> +++ b/tracecmd/trace-msg.c
> @@ -107,6 +107,11 @@ struct tracecmd_msg {
>  	void					*buf;
>  } __attribute__((packed));
>  
> +static int msg_buf_len(struct tracecmd_msg *msg)

I changed this to:

static inline int msg_buf_len(...)

-- Steve

> +{
> +	return ntohl(msg->hdr.size) - MSG_HDR_LEN - ntohl(msg->hdr.cmd_size);
> +}
> +
>  static int msg_write(int fd, struct tracecmd_msg *msg)
>  {
>  	int cmd = ntohl(msg->hdr.cmd);
> @@ -425,7 +430,7 @@ int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
>  		goto error;
>  	}
>  
> -	buf_len = ntohl(msg.hdr.size) - MSG_HDR_LEN - ntohl(msg.hdr.cmd_size);
> +	buf_len = msg_buf_len(&msg);
>  	if (buf_len <= 0) {
>  		ret = -EINVAL;
>  		goto error;
> @@ -541,7 +546,7 @@ int tracecmd_msg_initial_setting(struct tracecmd_msg_handle *msg_handle)
>  		goto error;
>  	}
>  
> -	buf_len = ntohl(msg.hdr.size) - MSG_HDR_LEN - ntohl(msg.hdr.cmd_size);
> +	buf_len = msg_buf_len(&msg);
>  	if (buf_len < 0) {
>  		ret = -EINVAL;
>  		goto error;
> @@ -685,7 +690,7 @@ int tracecmd_msg_read_data(struct tracecmd_msg_handle *msg_handle, int ofd)
>  			goto next;
>  		}
>  
> -		n = ntohl(msg.hdr.size) - MSG_HDR_LEN - ntohl(msg.hdr.cmd_size);
> +		n = msg_buf_len(&msg);
>  		t = n;
>  		s = 0;
>  		while (t > 0) {


      reply	other threads:[~2019-03-15 19:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 15:33 [PATCH 0/3] Switch V3 messages to text encoding of variable length buffer Slavomir Kaslev
2019-03-15 15:33 ` [PATCH 1/3] trace-cmd: Use text encoding for options in protocol V3 Slavomir Kaslev
2019-03-15 15:33 ` [PATCH 2/3] trace-cmd: Use text encoding for transmitting ports " Slavomir Kaslev
2019-03-15 15:33 ` [PATCH 3/3] trace-cmd: Add msg_buf_len() function Slavomir Kaslev
2019-03-15 19:08   ` Steven Rostedt [this message]

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=20190315150836.7e2bc4f3@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=kaslevs@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=slavomir.kaslev@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.