On Mon, 9 Dec 2013 11:05:19 -0500, Steven Rostedt wrote: > On Mon, 9 Dec 2013 14:34:01 +0900 > Namhyung Kim <[email protected]> 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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

