On Tue, 2026-10-13 at 08:14 +0200, Nam Cao wrote:
> Gabriele Monaco <[email protected]> writes:
> 
> > Functions like model_get_event_name() and model_get_state_name() are
> > shared with BPF monitors, however those programs don't play nice with
> > string pointers without fixed length and the event_name and state_name
> > arrays need to be defined differently. This gets the compiler to notice
> > those are const char and the above function discard the const qualifier.
> > 
> > Drop the warning by casting the result to (char *). Note, a cleaner
> > solution would require to modify all callers, but that would require
> > changing every single monitor's tracepoint and the advantage is minimal.
> 
> I prefer the cleaner solution. Just mass replace "char *" with
> "const char *", and manually fix up a few errors and we are done.

The reason I initially didn't do this was that some lines get beyond 100
characters adding the const, so I'd need to break them and make rvgen even more
complicated to generate things (TL;DR still laziness).

I'm actually taking a different approach and storing everything in macros like:

#define DEFINE_DA_EVENT(name)                                           \
        DEFINE_EVENT(event_da_monitor, name,                            \
                TP_PROTO(char *state, char *event,                      \
                         char *next_state, bool final_state),           \
                TP_ARGS(state, event, next_state, final_state))

So both per-monitor trace headers and rvgen get simpler and if we ever need to
change something again, it comes for free.

Gabriele


Reply via email to