Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tracing: Add trace_seq_pop() and seq_buf_pop()

In order to allow an interface to remove an added character from the
trace_seq and seq_buf descriptors, add helper functions trace_seq_pop()
and seq_buf_pop().

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Takaya Saeki <takayas@google.com>
Cc: Tom Zanussi <zanussi@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ian Rogers <irogers@google.com>
Cc: Douglas Raillard <douglas.raillard@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Link: https://lore.kernel.org/20251028231148.594898736@kernel.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+30
+17
include/linux/seq_buf.h
··· 149 149 } 150 150 } 151 151 152 + /** 153 + * seq_buf_pop - pop off the last written character 154 + * @s: the seq_buf handle 155 + * 156 + * Removes the last written character to the seq_buf @s. 157 + * 158 + * Returns the last character or -1 if it is empty. 159 + */ 160 + static inline int seq_buf_pop(struct seq_buf *s) 161 + { 162 + if (!s->len) 163 + return -1; 164 + 165 + s->len--; 166 + return (unsigned int)s->buffer[s->len]; 167 + } 168 + 152 169 extern __printf(2, 3) 153 170 int seq_buf_printf(struct seq_buf *s, const char *fmt, ...); 154 171 extern __printf(2, 0)
+13
include/linux/trace_seq.h
··· 80 80 return s->full || seq_buf_has_overflowed(&s->seq); 81 81 } 82 82 83 + /** 84 + * trace_seq_pop - pop off the last written character 85 + * @s: trace sequence descriptor 86 + * 87 + * Removes the last written character to the trace_seq @s. 88 + * 89 + * Returns the last character or -1 if it is empty. 90 + */ 91 + static inline int trace_seq_pop(struct trace_seq *s) 92 + { 93 + return seq_buf_pop(&s->seq); 94 + } 95 + 83 96 /* 84 97 * Currently only defined when tracing is enabled. 85 98 */