Commit c5b44095 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing warning fix from Steven Rostedt:
 "Make the GCC 9 warning for sub struct memset go away.

  GCC 9 now warns about calling memset() on partial structures when it
  goes across multiple fields. This adds a helper for the place in
  tracing that does this type of clearing of a structure"

* tag 'trace-v5.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  tracing: Silence GCC 9 array bounds warning
parents 862f0a32 0c97bf86
...@@ -8910,12 +8910,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) ...@@ -8910,12 +8910,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
cnt++; cnt++;
/* reset all but tr, trace, and overruns */ trace_iterator_reset(&iter);
memset(&iter.seq, 0,
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
iter.iter_flags |= TRACE_FILE_LAT_FMT; iter.iter_flags |= TRACE_FILE_LAT_FMT;
iter.pos = -1;
if (trace_find_next_entry_inc(&iter) != NULL) { if (trace_find_next_entry_inc(&iter) != NULL) {
int ret; int ret;
......
...@@ -1966,4 +1966,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { } ...@@ -1966,4 +1966,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { }
extern struct trace_iterator *tracepoint_print_iter; extern struct trace_iterator *tracepoint_print_iter;
/*
* Reset the state of the trace_iterator so that it can read consumed data.
* Normally, the trace_iterator is used for reading the data when it is not
* consumed, and must retain state.
*/
static __always_inline void trace_iterator_reset(struct trace_iterator *iter)
{
const size_t offset = offsetof(struct trace_iterator, seq);
/*
* Keep gcc from complaining about overwriting more than just one
* member in the structure.
*/
memset((char *)iter + offset, 0, sizeof(struct trace_iterator) - offset);
iter->pos = -1;
}
#endif /* _LINUX_KERNEL_TRACE_H */ #endif /* _LINUX_KERNEL_TRACE_H */
...@@ -37,12 +37,8 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file) ...@@ -37,12 +37,8 @@ static void ftrace_dump_buf(int skip_entries, long cpu_file)
if (skip_entries) if (skip_entries)
kdb_printf("(skipping %d entries)\n", skip_entries); kdb_printf("(skipping %d entries)\n", skip_entries);
/* reset all but tr, trace, and overruns */ trace_iterator_reset(&iter);
memset(&iter.seq, 0,
sizeof(struct trace_iterator) -
offsetof(struct trace_iterator, seq));
iter.iter_flags |= TRACE_FILE_LAT_FMT; iter.iter_flags |= TRACE_FILE_LAT_FMT;
iter.pos = -1;
if (cpu_file == RING_BUFFER_ALL_CPUS) { if (cpu_file == RING_BUFFER_ALL_CPUS) {
for_each_tracing_cpu(cpu) { for_each_tracing_cpu(cpu) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment