mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@redhat.com, alexander.shishkin@linux.intel.com,
	namhyung@kernel.org, kstewart@linuxfoundation.org,
	gregkh@linuxfoundation.org, jeremie.galarneau@efficios.com,
	shawn@git.icu, tstoyanov@vmware.com, tglx@linutronix.de,
	alexey.budankov@linux.intel.com, adrian.hunter@intel.com,
	songliubraving@fb.com, ravi.bangoria@linux.ibm.com
Subject: Re: [PATCH V1]Perf: Return error code for perf_session__new function on failure
Date: Thu, 22 Aug 2019 12:33:56 +0530	[thread overview]
Message-ID: <8e974fb4-c4e0-b1f3-0770-d5b9eafc8da3@linux.vnet.ibm.com> (raw)
In-Reply-To: <20190821070540.GA16609@krava>


On 21/08/19 12:35 PM, Jiri Olsa wrote:
> 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

ok, I think your point is correct,

"ret" contains value of conditional statement(&&), which is always 
either 0 or 1

will do following changes and send new version of patch

if (data->is_dir) {
        ret = perf_data__open_dir(data);
        if (ret)
                goto out_delete;
}

>>   		}
>>   	} 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)
>>


      reply	other threads:[~2019-08-22  7:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 11:21 Mamatha Inamdar
2019-08-20 19:37 ` Mukesh Ojha
2019-08-22 10:41   ` Mamatha Inamdar
2019-08-21  7:05 ` Jiri Olsa
2019-08-22  7:03   ` Mamatha Inamdar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e974fb4-c4e0-b1f3-0770-d5b9eafc8da3@linux.vnet.ibm.com \
    --to=mamatha4@linux.vnet.ibm.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeremie.galarneau@efficios.com \
    --cc=jolsa@redhat.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=shawn@git.icu \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=tstoyanov@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®