aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_seq.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-11-12 18:07:22 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-11-19 15:25:47 -0500
commitdba39448abb7340f86ae9b062f99d7acacb5d2d2 (patch)
tree8458bc1b3deda29028656637c84a5d0e10800578 /kernel/trace/trace_seq.c
parent183742f08c5532c0cd3c3d3fa184a26c092e2157 (diff)
tracing: Remove return values of most trace_seq_*() functions
The trace_seq_printf() and friends are used to store strings into a buffer that can be passed around from function to function. If the trace_seq buffer fills up, it will not print any more. The return values were somewhat inconsistant and using trace_seq_has_overflowed() was a better way to know if the write to the trace_seq buffer succeeded or not. Now that all users have removed reading the return value of the printf() type functions, they can safely return void and keep future users of them from reading the inconsistent values as well. Link: http://lkml.kernel.org/r/20141114011411.992510720@goodmis.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_seq.c')
-rw-r--r--kernel/trace/trace_seq.c84
1 files changed, 23 insertions, 61 deletions
diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
index b100994a17fe..fabfa0f190a3 100644
--- a/kernel/trace/trace_seq.c
+++ b/kernel/trace/trace_seq.c
@@ -69,20 +69,15 @@ int trace_print_seq(struct seq_file *m, struct trace_seq *s)
69 * trace_seq_printf() is used to store strings into a special 69 * trace_seq_printf() is used to store strings into a special
70 * buffer (@s). Then the output may be either used by 70 * buffer (@s). Then the output may be either used by
71 * the sequencer or pulled into another buffer. 71 * the sequencer or pulled into another buffer.
72 *
73 * Returns 1 if we successfully written all the contents to
74 * the buffer.
75 * Returns 0 if we the length to write is bigger than the
76 * reserved buffer space. In this case, nothing gets written.
77 */ 72 */
78int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) 73void trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
79{ 74{
80 unsigned int len = TRACE_SEQ_BUF_LEFT(s); 75 unsigned int len = TRACE_SEQ_BUF_LEFT(s);
81 va_list ap; 76 va_list ap;
82 int ret; 77 int ret;
83 78
84 if (s->full || !len) 79 if (s->full || !len)
85 return 0; 80 return;
86 81
87 va_start(ap, fmt); 82 va_start(ap, fmt);
88 ret = vsnprintf(s->buffer + s->len, len, fmt, ap); 83 ret = vsnprintf(s->buffer + s->len, len, fmt, ap);
@@ -91,12 +86,10 @@ int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
91 /* If we can't write it all, don't bother writing anything */ 86 /* If we can't write it all, don't bother writing anything */
92 if (ret >= len) { 87 if (ret >= len) {
93 s->full = 1; 88 s->full = 1;
94 return 0; 89 return;
95 } 90 }
96 91
97 s->len += ret; 92 s->len += ret;
98
99 return 1;
100} 93}
101EXPORT_SYMBOL_GPL(trace_seq_printf); 94EXPORT_SYMBOL_GPL(trace_seq_printf);
102 95
@@ -107,25 +100,18 @@ EXPORT_SYMBOL_GPL(trace_seq_printf);
107 * @nmaskbits: The number of bits that are valid in @maskp 100 * @nmaskbits: The number of bits that are valid in @maskp
108 * 101 *
109 * Writes a ASCII representation of a bitmask string into @s. 102 * Writes a ASCII representation of a bitmask string into @s.
110 *
111 * Returns 1 if we successfully written all the contents to
112 * the buffer.
113 * Returns 0 if we the length to write is bigger than the
114 * reserved buffer space. In this case, nothing gets written.
115 */ 103 */
116int trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp, 104void trace_seq_bitmask(struct trace_seq *s, const unsigned long *maskp,
117 int nmaskbits) 105 int nmaskbits)
118{ 106{
119 unsigned int len = TRACE_SEQ_BUF_LEFT(s); 107 unsigned int len = TRACE_SEQ_BUF_LEFT(s);
120 int ret; 108 int ret;
121 109
122 if (s->full || !len) 110 if (s->full || !len)
123 return 0; 111 return;
124 112
125 ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits); 113 ret = bitmap_scnprintf(s->buffer + s->len, len, maskp, nmaskbits);
126 s->len += ret; 114 s->len += ret;
127
128 return 1;
129} 115}
130EXPORT_SYMBOL_GPL(trace_seq_bitmask); 116EXPORT_SYMBOL_GPL(trace_seq_bitmask);
131 117
@@ -139,28 +125,24 @@ EXPORT_SYMBOL_GPL(trace_seq_bitmask);
139 * trace_seq_printf is used to store strings into a special 125 * trace_seq_printf is used to store strings into a special
140 * buffer (@s). Then the output may be either used by 126 * buffer (@s). Then the output may be either used by
141 * the sequencer or pulled into another buffer. 127 * the sequencer or pulled into another buffer.
142 *
143 * Returns how much it wrote to the buffer.
144 */ 128 */
145int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) 129void trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
146{ 130{
147 unsigned int len = TRACE_SEQ_BUF_LEFT(s); 131 unsigned int len = TRACE_SEQ_BUF_LEFT(s);
148 int ret; 132 int ret;
149 133
150 if (s->full || !len) 134 if (s->full || !len)
151 return 0; 135 return;
152 136
153 ret = vsnprintf(s->buffer + s->len, len, fmt, args); 137 ret = vsnprintf(s->buffer + s->len, len, fmt, args);
154 138
155 /* If we can't write it all, don't bother writing anything */ 139 /* If we can't write it all, don't bother writing anything */
156 if (ret >= len) { 140 if (ret >= len) {
157 s->full = 1; 141 s->full = 1;
158 return 0; 142 return;
159 } 143 }
160 144
161 s->len += ret; 145 s->len += ret;
162
163 return len;
164} 146}
165EXPORT_SYMBOL_GPL(trace_seq_vprintf); 147EXPORT_SYMBOL_GPL(trace_seq_vprintf);
166 148
@@ -178,28 +160,24 @@ EXPORT_SYMBOL_GPL(trace_seq_vprintf);
178 * 160 *
179 * This function will take the format and the binary array and finish 161 * This function will take the format and the binary array and finish
180 * the conversion into the ASCII string within the buffer. 162 * the conversion into the ASCII string within the buffer.
181 *
182 * Returns how much it wrote to the buffer.
183 */ 163 */
184int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary) 164void trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary)
185{ 165{
186 unsigned int len = TRACE_SEQ_BUF_LEFT(s); 166 unsigned int len = TRACE_SEQ_BUF_LEFT(s);
187 int ret; 167 int ret;
188 168
189 if (s->full || !len) 169 if (s->full || !len)
190 return 0; 170 return;
191 171
192 ret = bstr_printf(s->buffer + s->len, len, fmt, binary); 172 ret = bstr_printf(s->buffer + s->len, len, fmt, binary);
193 173
194 /* If we can't write it all, don't bother writing anything */ 174 /* If we can't write it all, don't bother writing anything */
195 if (ret >= len) { 175 if (ret >= len) {
196 s->full = 1; 176 s->full = 1;
197 return 0; 177 return;
198 } 178 }
199 179
200 s->len += ret; 180 s->len += ret;
201
202 return len;
203} 181}
204EXPORT_SYMBOL_GPL(trace_seq_bprintf); 182EXPORT_SYMBOL_GPL(trace_seq_bprintf);
205 183
@@ -212,25 +190,21 @@ EXPORT_SYMBOL_GPL(trace_seq_bprintf);
212 * copy to user routines. This function records a simple string 190 * copy to user routines. This function records a simple string
213 * into a special buffer (@s) for later retrieval by a sequencer 191 * into a special buffer (@s) for later retrieval by a sequencer
214 * or other mechanism. 192 * or other mechanism.
215 *
216 * Returns how much it wrote to the buffer.
217 */ 193 */
218int trace_seq_puts(struct trace_seq *s, const char *str) 194void trace_seq_puts(struct trace_seq *s, const char *str)
219{ 195{
220 unsigned int len = strlen(str); 196 unsigned int len = strlen(str);
221 197
222 if (s->full) 198 if (s->full)
223 return 0; 199 return;
224 200
225 if (len > TRACE_SEQ_BUF_LEFT(s)) { 201 if (len > TRACE_SEQ_BUF_LEFT(s)) {
226 s->full = 1; 202 s->full = 1;
227 return 0; 203 return;
228 } 204 }
229 205
230 memcpy(s->buffer + s->len, str, len); 206 memcpy(s->buffer + s->len, str, len);
231 s->len += len; 207 s->len += len;
232
233 return len;
234} 208}
235EXPORT_SYMBOL_GPL(trace_seq_puts); 209EXPORT_SYMBOL_GPL(trace_seq_puts);
236 210
@@ -243,22 +217,18 @@ EXPORT_SYMBOL_GPL(trace_seq_puts);
243 * copy to user routines. This function records a simple charater 217 * copy to user routines. This function records a simple charater
244 * into a special buffer (@s) for later retrieval by a sequencer 218 * into a special buffer (@s) for later retrieval by a sequencer
245 * or other mechanism. 219 * or other mechanism.
246 *
247 * Returns how much it wrote to the buffer.
248 */ 220 */
249int trace_seq_putc(struct trace_seq *s, unsigned char c) 221void trace_seq_putc(struct trace_seq *s, unsigned char c)
250{ 222{
251 if (s->full) 223 if (s->full)
252 return 0; 224 return;
253 225
254 if (TRACE_SEQ_BUF_LEFT(s) < 1) { 226 if (TRACE_SEQ_BUF_LEFT(s) < 1) {
255 s->full = 1; 227 s->full = 1;
256 return 0; 228 return;
257 } 229 }
258 230
259 s->buffer[s->len++] = c; 231 s->buffer[s->len++] = c;
260
261 return 1;
262} 232}
263EXPORT_SYMBOL_GPL(trace_seq_putc); 233EXPORT_SYMBOL_GPL(trace_seq_putc);
264 234
@@ -271,23 +241,19 @@ EXPORT_SYMBOL_GPL(trace_seq_putc);
271 * There may be cases where raw memory needs to be written into the 241 * There may be cases where raw memory needs to be written into the
272 * buffer and a strcpy() would not work. Using this function allows 242 * buffer and a strcpy() would not work. Using this function allows
273 * for such cases. 243 * for such cases.
274 *
275 * Returns how much it wrote to the buffer.
276 */ 244 */
277int trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len) 245void trace_seq_putmem(struct trace_seq *s, const void *mem, unsigned int len)
278{ 246{
279 if (s->full) 247 if (s->full)
280 return 0; 248 return;
281 249
282 if (len > TRACE_SEQ_BUF_LEFT(s)) { 250 if (len > TRACE_SEQ_BUF_LEFT(s)) {
283 s->full = 1; 251 s->full = 1;
284 return 0; 252 return;
285 } 253 }
286 254
287 memcpy(s->buffer + s->len, mem, len); 255 memcpy(s->buffer + s->len, mem, len);
288 s->len += len; 256 s->len += len;
289
290 return len;
291} 257}
292EXPORT_SYMBOL_GPL(trace_seq_putmem); 258EXPORT_SYMBOL_GPL(trace_seq_putmem);
293 259
@@ -303,20 +269,17 @@ EXPORT_SYMBOL_GPL(trace_seq_putmem);
303 * This is similar to trace_seq_putmem() except instead of just copying the 269 * This is similar to trace_seq_putmem() except instead of just copying the
304 * raw memory into the buffer it writes its ASCII representation of it 270 * raw memory into the buffer it writes its ASCII representation of it
305 * in hex characters. 271 * in hex characters.
306 *
307 * Returns how much it wrote to the buffer.
308 */ 272 */
309int trace_seq_putmem_hex(struct trace_seq *s, const void *mem, 273void trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
310 unsigned int len) 274 unsigned int len)
311{ 275{
312 unsigned char hex[HEX_CHARS]; 276 unsigned char hex[HEX_CHARS];
313 const unsigned char *data = mem; 277 const unsigned char *data = mem;
314 unsigned int start_len; 278 unsigned int start_len;
315 int i, j; 279 int i, j;
316 int cnt = 0;
317 280
318 if (s->full) 281 if (s->full)
319 return 0; 282 return;
320 283
321 while (len) { 284 while (len) {
322 start_len = min(len, HEX_CHARS - 1); 285 start_len = min(len, HEX_CHARS - 1);
@@ -335,9 +298,8 @@ int trace_seq_putmem_hex(struct trace_seq *s, const void *mem,
335 len -= j / 2; 298 len -= j / 2;
336 hex[j++] = ' '; 299 hex[j++] = ' ';
337 300
338 cnt += trace_seq_putmem(s, hex, j); 301 trace_seq_putmem(s, hex, j);
339 } 302 }
340 return cnt;
341} 303}
342EXPORT_SYMBOL_GPL(trace_seq_putmem_hex); 304EXPORT_SYMBOL_GPL(trace_seq_putmem_hex);
343 305