All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Subject: [PATCH 2/6] libtraceevent: Fix tep_kbuffer() to have kbuf assign long_size
Date: Sun, 24 Dec 2023 14:15:59 -0500	[thread overview]
Message-ID: <20231224191813.1076074-3-rostedt@goodmis.org> (raw)
In-Reply-To: <20231224191813.1076074-1-rostedt@goodmis.org>

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

If the tep handle that returns the kbuf from tep_kbuffer() did not have its
long_size initialized, neither will the kbuffer it returns. This can cause
inconsistent results. Default the long_size to the "commit" size of the header
page as that should also be the size of long.

Fixes: 21ba6336 ("libtraceevent: Add kbuffer_create()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/parse-utils.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/parse-utils.c b/src/parse-utils.c
index 9c38e1e644d7..b434e24e44df 100644
--- a/src/parse-utils.c
+++ b/src/parse-utils.c
@@ -137,6 +137,11 @@ struct kbuffer *tep_kbuffer(struct tep_handle *tep)
 	int long_size;
 
 	long_size = tep_get_long_size(tep);
+
+	/* If the long_size is not set, then use the commit size */
+	if (!long_size)
+		long_size = tep_get_header_page_size(tep);
+
 	if (long_size == 8)
 		long_size = KBUFFER_LSIZE_8;
 	else
-- 
2.42.0


  parent reply	other threads:[~2023-12-24 19:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-24 19:15 [PATCH 0/6] libtraceevent/kbuffer: Add more kbuffer APIs Steven Rostedt
2023-12-24 19:15 ` [PATCH 1/6] libtraceevent: Add tep_get_sub_buffer_commit_offset() Steven Rostedt
2023-12-24 19:15 ` Steven Rostedt [this message]
2023-12-24 19:16 ` [PATCH 3/6] kbuffer: Add kbuffer_read_buffer() Steven Rostedt
2023-12-24 19:16 ` [PATCH 4/6] kbuffer: Add kbuffer_dup() Steven Rostedt
2023-12-24 19:16 ` [PATCH 5/6] kbuffer: Add kbuffer_subbuffer() API Steven Rostedt
2023-12-24 19:16 ` [PATCH 6/6] kbuffer: Add kbuffer_refresh() API Steven Rostedt

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=20231224191813.1076074-3-rostedt@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    /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.