Hi Arnaldo,

On Fri, 13 Dec 2013 11:52:04 -0300, Arnaldo Carvalho de Melo wrote:
>> -                            str = malloc_or_die(6);
>> +                            str = malloc(6);
>> +                            if (str == NULL)
>> +                                    break;
>>                              if (val)
>>                                      strcpy(str, "TRUE");
>>                              else
>
> The malloc here can be combined with the strcpy, and the else clause
> gets immediately after:
>
>                               if (asprintf(&str, "%s", "TRUE") < 0)
>
>> @@ -2119,10 +2122,7 @@ static char *op_to_str(struct event_filter *filter, 
>> struct filter_arg *arg)
>>                      break;
>>              }
>>  
>> -            len = strlen(left) + strlen(right) + strlen(op) + 10;
>> -            str = malloc_or_die(len);
>> -            snprintf(str, len, "(%s) %s (%s)",
>> -                     left, op, right);
>> +            asprintf(&str, "(%s) %s (%s)", left, op, right);
>>              break;
>
> I was unsure if str was NULL, it is already, at decl site, good :)
>
> All the rest is ok, so its just the malloc + strcpy that remains to be
> converted, do you want me to do it?

Hmm.. did you mean like this?

                str = NULL;
                if (val)
                        asprintf(&str, "TRUE");
                else
                        asprintf(&str, "FALSE");
                return str;

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

Reply via email to