It wasn't immediately obvious to me what these checks are supposed to
do. Explicitly checking against the min/max values should make the code
easier to understand.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/51>
if (pa_atol(s, &l) < 0)
return -1;
- if ((int32_t) l != l) {
+ if (l < INT32_MIN || l > INT32_MAX) {
errno = ERANGE;
return -1;
}
return -1;
}
- if ((uint32_t) l != l) {
+ if (l > UINT32_MAX) {
errno = ERANGE;
return -1;
}
return -1;
}
- if ((uint64_t) l != l) {
+ if (l > UINT64_MAX) {
errno = ERANGE;
return -1;
}
*ret_l = l;
- if ((int64_t) l != l) {
+ if (l < INT64_MIN || l > INT64_MAX) {
errno = ERANGE;
return -1;
}