On Tue, 22 Feb 2022 16:25:35 +0200 Yordan Karadzhov <y.karadz@xxxxxxxxx> 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