On 2/19/14, 7:43 PM, Wang Shilong wrote:
> On 02/20/2014 09:39 AM, Eric Sandeen wrote:
>> On 2/19/14, 7:30 PM, Wang Shilong wrote:

...

>>> +    /*
>>> +     * if we pass a negative number to strtoull,
>>> +     * it will return an unexpected number to us,
>>> +     * so let's do the check ourselves firstly.
>>> +     */
>>> +    if (str[0] == '-') {
>>> +        fprintf(stderr, "ERROR: %s may be negative value.\n", str);
>> well, it _is_ a negative value right?  (vs. "may be")
>>
>> So perhaps:
>>
>> fprintf(stderr, "ERROR: %s: negative value is invalid.\n", str);
> I use "may be" because the following case:
> 
> -123xxxx, -abcd..... something like these, these string are invalid,
> but they are not negative number...So i have not thought a better idea
> to tell user what is wrong with input.:-)

Ok; well, sorry for being nitpicky.  :)  But user error messages probably
should be very clear and unambiguous; we may as well do this right.

So what about this:

Do strtoull first, and *if* it passes numeric parsing, but str[0] == '-',
*then* say "ERROR: %s: negative value is invalid."

-Eric


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to