hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/tools/lib/traceevent/trace-seq.c
....@@ -3,6 +3,8 @@
33 * Copyright (C) 2009 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
44 *
55 */
6
+#include "trace-seq.h"
7
+
68 #include <stdio.h>
79 #include <stdlib.h>
810 #include <string.h>
....@@ -98,7 +100,8 @@
98100 * @fmt: printf format string
99101 *
100102 * It returns 0 if the trace oversizes the buffer's free
101
- * space, 1 otherwise.
103
+ * space, the number of characters printed, or a negative
104
+ * value in case of an error.
102105 *
103106 * The tracer may use either sequence operations or its own
104107 * copy to user routines. To simplify formating of a trace
....@@ -127,9 +130,10 @@
127130 goto try_again;
128131 }
129132
130
- s->len += ret;
133
+ if (ret > 0)
134
+ s->len += ret;
131135
132
- return 1;
136
+ return ret;
133137 }
134138
135139 /**
....@@ -137,6 +141,10 @@
137141 * @s: trace sequence descriptor
138142 * @fmt: printf format string
139143 *
144
+ * It returns 0 if the trace oversizes the buffer's free
145
+ * space, the number of characters printed, or a negative
146
+ * value in case of an error.
147
+ * *
140148 * The tracer may use either sequence operations or its own
141149 * copy to user routines. To simplify formating of a trace
142150 * trace_seq_printf is used to store strings into a special
....@@ -161,9 +169,10 @@
161169 goto try_again;
162170 }
163171
164
- s->len += ret;
172
+ if (ret > 0)
173
+ s->len += ret;
165174
166
- return len;
175
+ return ret;
167176 }
168177
169178 /**