On 02/09/2012 05:30 PM, Wanlong Gao wrote:
> On 02/09/2012 04:13 PM, Caspar Zhang wrote:
> 
>> +
>> +long safe_strtol(const char *file, const int lineno,
>> +        void (cleanup_fn)(void), char *str, long min, long max)
>> +{
>> +    int rval;
>> +    char *endptr;
>> +
>> +    rval = strtol(str, &endptr, 10);
>> +    if (rval == LONG_MAX || rval == LONG_MIN)
> 
> 
> Shouldn't we check the errno here?

Ah yes. I'll make a v2 soon.

> 
> Thanks
> -Wanlong Gao
> 
>> +            tst_brkm(TBROK|TERRNO, cleanup_fn, "strtol failed at %s:%d",
>> +                     file, lineno);
>> +    if (rval >= max || rval <= min)
>> +            tst_brkm(TBROK, cleanup_fn,
>> +                     "converted value out of range: %ld - %ld",
>> +                     min, max);
>> +    if (endptr == str || (*endptr != '\0' && *endptr != '\n'))
>> +            tst_brkm(TBROK, cleanup_fn, "Invalid value: %s", str);
>> +
>> +    return rval;
>> +}
> 
> 


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to