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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Dec 2013 09:48:49 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Jiri Olsa <jolsa@...hat.com>
Cc:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Namhyung Kim <namhyung.kim@....com>
Subject: Re: [PATCH 06/14] tools lib traceevent: Get rid of malloc_or_die() in find_event()

On Mon, 9 Dec 2013 12:03:50 +0100, Jiri Olsa wrote:
> On Mon, Dec 09, 2013 at 02:34:03PM +0900, Namhyung Kim wrote:
>> Make it return -2 to distinguish malloc allocation failure.
>> 
>> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
>> ---
>>  tools/lib/traceevent/parse-filter.c | 17 ++++++++++++++---
>>  1 file changed, 14 insertions(+), 3 deletions(-)
>> 
>> diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
>> index e9d17bfcdffd..06e5af9f8fc4 100644
>> --- a/tools/lib/traceevent/parse-filter.c
>> +++ b/tools/lib/traceevent/parse-filter.c
>> @@ -301,7 +301,10 @@ find_event(struct pevent *pevent, struct event_list **events,
>>  		sys_name = NULL;
>>  	}
>>  
>> -	reg = malloc_or_die(strlen(event_name) + 3);
>> +	reg = malloc(strlen(event_name) + 3);
>> +	if (reg == NULL)
>> +		return -2;
>> +
>
> I guess we dont need error defines or enums when this is just
> static function, but at least please add some comment (description)
> of return values like in pevent_filter_match function

Well, probably we can pass the error_str to find_event().

For comments, I think we only add a formal comment on the external APIs.
So it'll look like this:

/* 
 * Returns 0 if succeeded, -1 if not matched or invalid regex,
 * -2 if memory allocation failed.
 */

What do you think?

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ