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]
Message-ID: <874n6hlcur.fsf@sejong.aot.lge.com>
Date:	Tue, 10 Dec 2013 10:21:48 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...nel.org>, Jiri Olsa <jolsa@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Namhyung Kim <namhyung.kim@....com>
Subject: Re: [PATCH 04/14] tools lib traceevent: Get rid of malloc_or_die() allocate_arg()

On Mon, 9 Dec 2013 11:05:19 -0500, Steven Rostedt wrote:
> On Mon,  9 Dec 2013 14:34:01 +0900
> Namhyung Kim <namhyung@...nel.org> wrote:
>
>> @@ -409,8 +408,10 @@ create_arg_op(enum filter_op_type btype)
>>  	struct filter_arg *arg;
>>  
>>  	arg = allocate_arg();
>> -	arg->type = FILTER_ARG_OP;
>> -	arg->op.type = btype;
>> +	if (arg) {
>> +		arg->type = FILTER_ARG_OP;
>> +		arg->op.type = btype;
>> +	}
>>  
>>  	return arg;
>>  }
>> @@ -421,8 +422,10 @@ create_arg_exp(enum filter_exp_type etype)
>>  	struct filter_arg *arg;
>>  
>>  	arg = allocate_arg();
>> -	arg->type = FILTER_ARG_EXP;
>> -	arg->op.type = etype;
>> +	if (arg) {
>> +		arg->type = FILTER_ARG_EXP;
>> +		arg->op.type = etype;
>> +	}
>>  
>>  	return arg;
>>  }
>> @@ -433,9 +436,11 @@ create_arg_cmp(enum filter_exp_type etype)
>>  	struct filter_arg *arg;
>>  
>>  	arg = allocate_arg();
>> -	/* Use NUM and change if necessary */
>> -	arg->type = FILTER_ARG_NUM;
>> -	arg->op.type = etype;
>> +	if (arg) {
>> +		/* Use NUM and change if necessary */
>> +		arg->type = FILTER_ARG_NUM;
>> +		arg->op.type = etype;
>> +	}
>>  
>>  	return arg;
>>  }
>> @@ -896,8 +901,10 @@ static struct filter_arg *collapse_tree(struct filter_arg *arg)
>>  	case FILTER_VAL_FALSE:
>>  		free_arg(arg);
>>  		arg = allocate_arg();
>> -		arg->type = FILTER_ARG_BOOLEAN;
>> -		arg->boolean.value = ret == FILTER_VAL_TRUE;
>> +		if (arg) {
>> +			arg->type = FILTER_ARG_BOOLEAN;
>> +			arg->boolean.value = ret == FILTER_VAL_TRUE;
>> +		}
>
> Just a nit, but I wonder if all these would look nicer if we just did:
>
> 	arg = allocate_arg();
> 	if (!arg)
> 		return NULL;
> 	[...]
>
> Instead of doing the work within an if statement.

Sure, no problem.

>
> Also, I prefer if (!arg) over if (arg == NULL), but I'm not going to
> fight over that ;-)

Yeah, it's about preference.  I can do it your way from now on if you
want while as you can see it's more error-prone - but no, I didn't do it
intentionally because of that. ;-)

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