Messages in this thread | | | From | Irina Tirdea <> | Date | Tue, 16 Oct 2012 02:05:58 +0300 | Subject | Re: [PATCH v3 8/8] perf stat: implement --big-num grouping |
| |
>> + >> + *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
| |