[RFC PATCH 08/20] rv: Cast result of model_get_*_name()
From: Gabriele Monaco
Date: Mon Aug 31 2026 - 05:19:41 EST
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.
Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
---
include/rv/automata.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/rv/automata.h b/include/rv/automata.h
index 4a4eb40cf09a..3c7070e91d11 100644
--- a/include/rv/automata.h
+++ b/include/rv/automata.h
@@ -27,7 +27,7 @@ static char *model_get_state_name(enum states state)
if ((state < 0) || (state >= STATE_MAX))
return "INVALID";
- return RV_AUTOMATON_NAME.state_names[state];
+ return (char *)RV_AUTOMATON_NAME.state_names[state];
}
/*
@@ -38,7 +38,7 @@ static char *model_get_event_name(enum events event)
if ((event < 0) || (event >= EVENT_MAX))
return "INVALID";
- return RV_AUTOMATON_NAME.event_names[event];
+ return (char *)RV_AUTOMATON_NAME.event_names[event];
}
/*
--
2.55.0