Re: [PATCH v3 8/8] perf stat: implement --big-num grouping

From: Irina Tirdea
Date: Mon Oct 15 2012 - 19:06:09 EST


>> +
>> + *gnumber = NULL;
>> + /* No grouping */
>> + if (thousands_sep == NULL || grouping == NULL ||
>> + *thousands_sep == '\0' || *grouping == CHAR_MAX || *grouping <= 0) {
>> + *gnumber = strdup(number);
>> + if (*gnumber == NULL)
>> + ret = -ENOMEM;
>> + goto out;
>
> Humm, so we bail out unconditionally? :-)
>
> this should be:
>
> if (*gnumber == NULL)
> goto out;
>> + }

The initial code was correct, although not clear. We bail out if there
is no grouping (the outer if), set gnumber to a copy of number and
return success. If we cannot allocate a copy of gnumber then we return
the error code.
However, this is no longer needed since it is already done when we
call the grouping function. So I'll just return error in case there is
no grouping and the calling code will take care to use the original
number (with no grouping).

I'll also fix your other comments and submit a new version.

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