Re: [PATCH 3/3] tools lib traceevent: Fix to set uninitialized variables
From: Arnaldo Carvalho de Melo
Date: Tue Oct 18 2016 - 13:59:59 EST
One more.
Em Mon, Oct 17, 2016 at 11:17:12PM +0900, Honggyu Kim escreveu:
> This patch fixes uninitialized variables to remove remaining compiler
> warnings as follows:
>
> event-parse.c: In function âpevent_find_event_by_nameâ:
> event-parse.c:3513:21: warning: âeventâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> pevent->last_event = event;
> ^
> event-parse.c: In function âpevent_data_lat_fmtâ:
> event-parse.c:5156:20: warning: âmigrate_disableâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> trace_seq_printf(s, "%d", migrate_disable);
> ^
> event-parse.c:5163:20: warning: âlock_depthâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> trace_seq_printf(s, "%d", lock_depth);
> ^
> event-parse.c: In function âpevent_event_infoâ:
> event-parse.c:5060:18: warning: âlen_argâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> print_str_arg(&p, data, size, event,
> ^
> event-parse.c:4846:6: note: âlen_argâ was declared here
> int len_arg;
> ^
> ...
> kbuffer-parse.c: In function â__old_next_eventâ:
> kbuffer-parse.c:339:27: warning: âlengthâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> kbuf->next = kbuf->index + length;
> ^
> kbuffer-parse.c:297:15: note: âlengthâ was declared here
> unsigned int length;
> ^
>
> Signed-off-by: Honggyu Kim <hong.gyu.kim@xxxxxxx>
> ---
> tools/lib/traceevent/event-parse.c | 8 ++++----
> tools/lib/traceevent/kbuffer-parse.c | 2 +-
> tools/lib/traceevent/plugin_function.c | 2 +-
> 3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index 664c90c..2fb9338 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -3490,7 +3490,7 @@ struct event_format *
> pevent_find_event_by_name(struct pevent *pevent,
> const char *sys, const char *name)
> {
> - struct event_format *event;
> + struct event_format *event = NULL;
> int i;
>
> if (pevent->last_event &&
> @@ -4843,7 +4843,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
> char format[32];
> int show_func;
> int len_as_arg;
> - int len_arg;
> + int len_arg = 0;
> int len;
> int ls;
>
> @@ -5102,8 +5102,8 @@ void pevent_data_lat_fmt(struct pevent *pevent,
> static int migrate_disable_exists;
> unsigned int lat_flags;
> unsigned int pc;
> - int lock_depth;
> - int migrate_disable;
> + int lock_depth = -1;
> + int migrate_disable = 0;
> int hardirq;
> int softirq;
> void *data = record->data;
> diff --git a/tools/lib/traceevent/kbuffer-parse.c b/tools/lib/traceevent/kbuffer-parse.c
> index 65984f1..fc8f20c 100644
> --- a/tools/lib/traceevent/kbuffer-parse.c
> +++ b/tools/lib/traceevent/kbuffer-parse.c
> @@ -294,7 +294,7 @@ static unsigned int old_update_pointers(struct kbuffer *kbuf)
> unsigned int type;
> unsigned int len;
> unsigned int delta;
> - unsigned int length;
> + unsigned int length = 0;
> void *ptr = kbuf->data + kbuf->curr;
>
> type_len_ts = read_4(kbuf, ptr);
> diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
> index a00ec19..42dbf73 100644
> --- a/tools/lib/traceevent/plugin_function.c
> +++ b/tools/lib/traceevent/plugin_function.c
> @@ -130,7 +130,7 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record,
> unsigned long long pfunction;
> const char *func;
> const char *parent;
> - int index;
> + int index = 0;
>
> if (pevent_get_field_val(s, event, "ip", record, &function, 1))
> return trace_seq_putc(s, '!');
> --
> 2.10.0.rc2.dirty