linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Yordan Karadzhov <y.karadz@gmail.com>
Cc: Beau Belgrave <beaub@linux.microsoft.com>,
	linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v1 1/3] libtracefs: Add user_events to libtracefs sources
Date: Tue, 22 Feb 2022 10:41:48 -0500	[thread overview]
Message-ID: <20220222104148.2d4b6905@gandalf.local.home> (raw)
In-Reply-To: <49f2d343-c265-6ebe-413e-c0d76e6c1cb9@gmail.com>

On Tue, 22 Feb 2022 16:25:35 +0200
Yordan Karadzhov <y.karadz@gmail.com> wrote:

> I personally think that, using variadic arguments in library APIs is a
> not a good idea, because this enforces that the caller must know the
> number of those arguments at compile time.
> 
> For me the original solution that uses an array of items is better.
> Or maybe we can have both as 2 different APIs.

Actually, I was using the va_args as an example. I really didn't care about
the implementation of the arguments, except that they need to be added
after the enable check.

For now, lets just keep the two functions to check for the event being
enabled and recording. I think the last names were the way to go:

	tracefs_user_event_enabled();
	tracefs_user_event_record();

And keep the record using the array. If we want a macro, we could do:

#define tracefs_user_event_trace(event, ...)				\
	do {								\
		if (tracefs_user_event_enabled(event)) {		\
			struct tracefs_uevent_item items[] = {		\
				##__VA_ARGS__,				\
				{ TRACEFS_UEVENT_END },			\
			}						\
			tracefs_user_event_record(event, items);	\
		}							\
	} while (0)

And the user could have:

	tracefs_user_event_trace(event,
		{ TRACEFS_UEVENT_vstring, strlen(msg)+1, .data = msg });

Again, for those that do not want compile time knowledge of the arguments,
you just use the normal interface, and those that want the helper, to use
the macro.

-- Steve


  reply	other threads:[~2022-02-22 15:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-18 22:50 [PATCH v1 0/3] libtracefs: Add APIs for user_events to libtracefs Beau Belgrave
2022-02-18 22:50 ` [PATCH v1 1/3] libtracefs: Add user_events to libtracefs sources Beau Belgrave
2022-02-21 11:34   ` Yordan Karadzhov
2022-02-21 17:57     ` Beau Belgrave
2022-02-21 19:16       ` Steven Rostedt
2022-02-22  6:27         ` Yordan Karadzhov
2022-02-22 14:00           ` Steven Rostedt
2022-02-22 14:25             ` Yordan Karadzhov
2022-02-22 15:41               ` Steven Rostedt [this message]
2022-02-22 16:59             ` Beau Belgrave
2022-02-22 17:10               ` Steven Rostedt
2022-02-22 17:08   ` Steven Rostedt
2022-02-22 17:31   ` Steven Rostedt
2022-02-22 17:39     ` Steven Rostedt
2022-02-22 17:46     ` Beau Belgrave
2022-02-22 18:59       ` Steven Rostedt
2022-02-18 22:50 ` [PATCH v1 2/3] libtracefs: Add documentation and sample code for user_events Beau Belgrave
2022-02-18 22:50 ` [PATCH v1 3/3] libtracefs: Add unit tests " Beau Belgrave
2022-02-22 17:20   ` Steven Rostedt
2022-02-22 17:34 ` [PATCH v1 0/3] libtracefs: Add APIs for user_events to libtracefs Steven Rostedt
2022-02-22 17:50   ` Beau Belgrave
2022-02-22 18:20     ` 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=20220222104148.2d4b6905@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=beaub@linux.microsoft.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@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 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).