Skip to content

Commit 58c5724

Browse files
mhiramatrostedt
authored andcommitted
tracing: Avoid -Warray-bounds warning for __rel_loc macro
Since -Warray-bounds checks the destination size from the type of given pointer, __assign_rel_str() macro gets warned because it passes the pointer to the 'u32' field instead of 'trace_event_raw_*' data structure. Pass the data address calculated from the 'trace_event_raw_*' instead of 'u32' __rel_loc field. Link: https://lkml.kernel.org/r/[email protected] Cc: Stephen Rothwell <[email protected]> Cc: Kees Cook <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> [ This did not fix the warning, but is still a nice clean up ] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent e629e7b commit 58c5724

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/trace/trace_events.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ TRACE_MAKE_SYSTEM_STR();
318318
#define __get_str(field) ((char *)__get_dynamic_array(field))
319319

320320
#undef __get_rel_dynamic_array
321-
#define __get_rel_dynamic_array(field) \
322-
((void *)(&__entry->__rel_loc_##field) + \
323-
sizeof(__entry->__rel_loc_##field) + \
321+
#define __get_rel_dynamic_array(field) \
322+
((void *)__entry + \
323+
offsetof(typeof(*__entry), __rel_loc_##field) + \
324+
sizeof(__entry->__rel_loc_##field) + \
324325
(__entry->__rel_loc_##field & 0xffff))
325326

326327
#undef __get_rel_dynamic_array_len

0 commit comments

Comments
 (0)