Messages in this thread Patch in this message | | | Subject | Re: [PATCH 3/9] perf util: Get rid of write_or_die() from trace-event-info.c | From | Steven Rostedt <> | Date | Tue, 19 Mar 2013 10:35:11 -0400 |
| |
On Tue, 2013-03-19 at 17:53 +0900, Namhyung Kim wrote:
> struct tracing_data *tracing_data_get(struct list_head *pattrs, > @@ -465,6 +516,7 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, > { > struct tracepoint_path *tps; > struct tracing_data *tdata; > + int err1, err2, err3, err4, err5, err6; > > output_fd = fd; > > @@ -498,12 +550,12 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, > output_fd = temp_fd; > } > > - tracing_data_header(); > - read_header_files(); > - read_ftrace_files(tps); > - read_event_files(tps); > - read_proc_kallsyms(); > - read_ftrace_printk(); > + err1 = tracing_data_header(); > + err2 = read_header_files(); > + err3 = read_ftrace_files(tps); > + err4 = read_event_files(tps); > + err5 = read_proc_kallsyms(); > + err6 = read_ftrace_printk();
ugly ugly ugly
What about: int err = 0;
err += tracing_data_header(); err += read_header_files(); [...]
if (err < 0) { free(tdata); tdata = NULL; }
Also, is the only clean up needed be freeing tdata?
-- Steve
> > /* > * All tracing data are stored by now, we can restore > @@ -515,22 +567,31 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, > output_fd = fd; > } > > + if (err1 + err2 + err3 + err4 + err5 + err6 < 0) { > + free(tdata); > + tdata = NULL; > + } > + > put_tracepoints_path(tps); > return tdata; > } >
| |