On 02/09/2012 05:46 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;


Ah, long rval?

> +     char *endptr;
> +
> +     rval = strtol(str, &endptr, 10);
> +     if ((errno == ERANGE && (rval == LONG_MAX || rval == LONG_MIN))
> +                 || (errno != 0 && rval == 0))
> +             tst_brkm(TBROK|TERRNO, cleanup_fn, "strtol failed at %s:%d",
> +                      file, lineno);
> +     if (rval >= max || rval <= min)


I'm not sure with this check. ;)

Thanks
-Wanlong Gao

> +             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