Re: [PATCH v1 1/3] libtracefs: Add user_events to libtracefs sources

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

 





On 22.02.22 г. 16:00 ч., Steven Rostedt wrote:
On Tue, 22 Feb 2022 08:27:31 +0200
Yordan Karadzhov <y.karadz@xxxxxxxxx> wrote:

I have one last question. Do you consider as a valid use case that
the library must support, someone to do a just 'test" without writing
after this, or to "write" without testing first?

Actually, that's a very good point.

I was thinking that I didn't like the "test" name, and was thinking of
having it be:

	if (tracefs_user_event_enabled(event)) {
		tracefs_user_event_record(event, ...);
	}

But I think you have a good point. Perhaps we should just have:

	tracefs_user_event_trace(event, ...);

and it do all the work. But it would need to be a macro, that does:

#define tracefs_user_event_trace(event, ...)			\

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.

Thanks!
Y.

	do {							\
		if (tracefs_user_event_enabled(event)) {	\
			tracefs_user_event_record(event, ##__VA_ARGS); \
		}						\
	} while (0)

Because we do not want to have the compiler process the arguments when
the event is not enabled. That would be too much overhead.

But as a macro, it would work.

Thoughts?

-- Steve



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

  Powered by Linux