[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190821070540.GA16609@krava>
Date: Wed, 21 Aug 2019 09:05:40 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Mamatha Inamdar <mamatha4@...ux.vnet.ibm.com>
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
mingo@...hat.com, alexander.shishkin@...ux.intel.com,
namhyung@...nel.org, kstewart@...uxfoundation.org,
gregkh@...uxfoundation.org, jeremie.galarneau@...icios.com,
shawn@....icu, tstoyanov@...are.com, tglx@...utronix.de,
alexey.budankov@...ux.intel.com, adrian.hunter@...el.com,
songliubraving@...com, ravi.bangoria@...ux.ibm.com
Subject: Re: [PATCH V1]Perf: Return error code for perf_session__new function
on failure
On Tue, Aug 20, 2019 at 04:51:21PM +0530, Mamatha Inamdar wrote:
SNIP
> #ifdef HAVE_ZSTD_SUPPORT
> static int perf_session__process_compressed_event(struct perf_session *session,
> @@ -183,6 +184,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
> struct perf_session *perf_session__new(struct perf_data *data,
> bool repipe, struct perf_tool *tool)
> {
> + int ret = -ENOMEM;
> struct perf_session *session = zalloc(sizeof(*session));
>
> if (!session)
> @@ -197,13 +199,15 @@ struct perf_session *perf_session__new(struct perf_data *data,
>
> perf_env__init(&session->header.env);
> if (data) {
> - if (perf_data__open(data))
> + ret = perf_data__open(data);
> + if (ret < 0)
> goto out_delete;
>
> session->data = data;
>
> if (perf_data__is_read(data)) {
> - if (perf_session__open(session) < 0)
> + ret = perf_session__open(session);
> + if (ret < 0)
> goto out_delete;
>
> /*
> @@ -218,7 +222,8 @@ struct perf_session *perf_session__new(struct perf_data *data,
> perf_evlist__init_trace_event_sample_raw(session->evlist);
>
> /* Open the directory data. */
> - if (data->is_dir && perf_data__open_dir(data))
> + ret = data->is_dir && perf_data__open_dir(data);
> + if (ret)
> goto out_delete;
will this return 1 in case of error?
jirka
> }
> } else {
> @@ -252,7 +257,7 @@ struct perf_session *perf_session__new(struct perf_data *data,
> out_delete:
> perf_session__delete(session);
> out:
> - return NULL;
> + return ERR_PTR(ret);
> }
>
> static void perf_session__delete_threads(struct perf_session *session)
>
Powered by blists - more mailing lists