diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-12-02 21:34:18 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-12-02 21:34:18 -0500 |
commit | aed1ae46b1db28c5b4e8054b5c55c281f7ea426e (patch) | |
tree | deffcffa510b28cadfdb2bfa6b9f34312a0d0810 | |
parent | ad3e3e234a0c561c08de21e63b4930ed965c7142 (diff) |
Added trace_seq_terminate
Added trace_seq_terminate that zeros out the buffer if the buffer
is not full. This is useful when data being returned may be used
in a printf directly or more data will be added to the trace_seq.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | parse-events.c | 10 | ||||
-rw-r--r-- | parse-events.h | 2 | ||||
-rw-r--r-- | trace-seq.c | 6 |
3 files changed, 11 insertions, 7 deletions
diff --git a/parse-events.c b/parse-events.c index 737bdde..7fad6eb 100644 --- a/parse-events.c +++ b/parse-events.c | |||
@@ -2881,8 +2881,7 @@ void pevent_data_lat_fmt(struct trace_seq *s, void *data, int size __unused) | |||
2881 | else | 2881 | else |
2882 | trace_seq_printf(s, "%d", lock_depth); | 2882 | trace_seq_printf(s, "%d", lock_depth); |
2883 | 2883 | ||
2884 | if (!s->full) | 2884 | trace_seq_terminate(s); |
2885 | trace_seq_putc(s, 0); | ||
2886 | } | 2885 | } |
2887 | 2886 | ||
2888 | int pevent_data_type(void *data) | 2887 | int pevent_data_type(void *data) |
@@ -2916,8 +2915,7 @@ void pevent_event_info(struct trace_seq *s, struct event *event, | |||
2916 | else | 2915 | else |
2917 | pretty_print(s, data, size, event); | 2916 | pretty_print(s, data, size, event); |
2918 | 2917 | ||
2919 | if (!s->full) | 2918 | trace_seq_terminate(s); |
2920 | trace_seq_putc(s, 0); | ||
2921 | } | 2919 | } |
2922 | 2920 | ||
2923 | void pevent_print_event(struct trace_seq *s, | 2921 | void pevent_print_event(struct trace_seq *s, |
@@ -2959,9 +2957,7 @@ void pevent_print_event(struct trace_seq *s, | |||
2959 | else | 2957 | else |
2960 | pretty_print(s, data, size, event); | 2958 | pretty_print(s, data, size, event); |
2961 | 2959 | ||
2962 | if (!s->full) | 2960 | trace_seq_terminate(s); |
2963 | trace_seq_putc(s, 0); | ||
2964 | |||
2965 | } | 2961 | } |
2966 | 2962 | ||
2967 | static int events_id_cmp(const void *a, const void *b) | 2963 | static int events_id_cmp(const void *a, const void *b) |
diff --git a/parse-events.h b/parse-events.h index edd2292..4459b52 100644 --- a/parse-events.h +++ b/parse-events.h | |||
@@ -42,6 +42,8 @@ extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) | |||
42 | extern int trace_seq_puts(struct trace_seq *s, const char *str); | 42 | extern int trace_seq_puts(struct trace_seq *s, const char *str); |
43 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); | 43 | extern int trace_seq_putc(struct trace_seq *s, unsigned char c); |
44 | 44 | ||
45 | extern void trace_seq_terminate(struct trace_seq *s); | ||
46 | |||
45 | extern int trace_seq_do_printf(struct trace_seq *s); | 47 | extern int trace_seq_do_printf(struct trace_seq *s); |
46 | 48 | ||
47 | 49 | ||
diff --git a/trace-seq.c b/trace-seq.c index 3143bbb..5fb474a 100644 --- a/trace-seq.c +++ b/trace-seq.c | |||
@@ -126,6 +126,12 @@ int trace_seq_putc(struct trace_seq *s, unsigned char c) | |||
126 | return 1; | 126 | return 1; |
127 | } | 127 | } |
128 | 128 | ||
129 | void trace_seq_terminate(struct trace_seq *s) | ||
130 | { | ||
131 | if (!s->full) | ||
132 | s->buffer[s->len] = 0; | ||
133 | } | ||
134 | |||
129 | int trace_seq_do_printf(struct trace_seq *s) | 135 | int trace_seq_do_printf(struct trace_seq *s) |
130 | { | 136 | { |
131 | return printf("%.*s%s", s->len, s->buffer, | 137 | return printf("%.*s%s", s->len, s->buffer, |