lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <8e974fb4-c4e0-b1f3-0770-d5b9eafc8da3@linux.vnet.ibm.com>
Date:   Thu, 22 Aug 2019 12:33:56 +0530
From:   Mamatha Inamdar <mamatha4@...ux.vnet.ibm.com>
To:     Jiri Olsa <jolsa@...hat.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 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)
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ