diff options
author | Tzvetomir Stoyanov <tstoyanov@vmware.com> | 2018-11-30 23:08:10 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-01-08 11:28:13 -0500 |
commit | 6d2d6fd7e3ee0daf0d8308741792b3ec41aafd0c (patch) | |
tree | 0cd6ace0970c8a4b818c1a8586d37c013d3e5b69 | |
parent | 2e4318a287bdf815140462257ab8697f5289a12f (diff) |
tools lib traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs
In order to make libtraceevent into a proper library, its API should be
straightforward.
The trace_seq_printf() and trace_seq_vprintf() APIs have inconsistent
returned values with the other trace_seq_* APIs.
This path changes the return logic of trace_seq_printf() and
trace_seq_vprintf() to return the number of printed characters, as the
other trace_seq_* related APIs.
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181201040852.485792891@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/traceevent/trace-seq.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/lib/traceevent/trace-seq.c b/tools/lib/traceevent/trace-seq.c index 8ff1d55954d1..8d5ecd2bf877 100644 --- a/tools/lib/traceevent/trace-seq.c +++ b/tools/lib/traceevent/trace-seq.c | |||
@@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s) | |||
100 | * @fmt: printf format string | 100 | * @fmt: printf format string |
101 | * | 101 | * |
102 | * It returns 0 if the trace oversizes the buffer's free | 102 | * It returns 0 if the trace oversizes the buffer's free |
103 | * space, 1 otherwise. | 103 | * space, the number of characters printed, or a negative |
104 | * value in case of an error. | ||
104 | * | 105 | * |
105 | * The tracer may use either sequence operations or its own | 106 | * The tracer may use either sequence operations or its own |
106 | * copy to user routines. To simplify formating of a trace | 107 | * copy to user routines. To simplify formating of a trace |
@@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
129 | goto try_again; | 130 | goto try_again; |
130 | } | 131 | } |
131 | 132 | ||
132 | s->len += ret; | 133 | if (ret > 0) |
134 | s->len += ret; | ||
133 | 135 | ||
134 | return 1; | 136 | return ret; |
135 | } | 137 | } |
136 | 138 | ||
137 | /** | 139 | /** |
@@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) | |||
139 | * @s: trace sequence descriptor | 141 | * @s: trace sequence descriptor |
140 | * @fmt: printf format string | 142 | * @fmt: printf format string |
141 | * | 143 | * |
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 | * * | ||
142 | * The tracer may use either sequence operations or its own | 148 | * The tracer may use either sequence operations or its own |
143 | * copy to user routines. To simplify formating of a trace | 149 | * copy to user routines. To simplify formating of a trace |
144 | * trace_seq_printf is used to store strings into a special | 150 | * trace_seq_printf is used to store strings into a special |
@@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | |||
163 | goto try_again; | 169 | goto try_again; |
164 | } | 170 | } |
165 | 171 | ||
166 | s->len += ret; | 172 | if (ret > 0) |
173 | s->len += ret; | ||
167 | 174 | ||
168 | return len; | 175 | return ret; |
169 | } | 176 | } |
170 | 177 | ||
171 | /** | 178 | /** |