Hi!
> +
> +long safe_strtol(const char *file, const int lineno,
> + void (cleanup_fn)(void), char *str, long min, long max)
> +{
> + long rval;
> + char *endptr;
I think that we should set errno to zero here as the call itself doesn't
clear it on success.
> +
> + 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)
> + 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);
I would consider printing the file and lineno in these two tst_brkm too
and add '' around the %s that is used to print the passed string.
> + return rval;
> +}
--
Cyril Hrubis
[email protected]
------------------------------------------------------------------------------
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