tracing: Silence GCC 9 array bounds warning
[sfrench/cifs-2.6.git] / kernel / trace / trace.h
index 82c70b63d37510261c011b1ce3f683719f8f22c3..005f08629b8bed8d9d6ec0bcc5a10255cc0d7094 100644 (file)
@@ -1966,4 +1966,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { }
 
 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 */