mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
core-util: Make range checks easier to read
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>
This commit is contained in:
parent
ff64defc13
commit
6722b2d8c4
1 changed files with 4 additions and 4 deletions
|
|
@ -2189,7 +2189,7 @@ int pa_atoi(const char *s, int32_t *ret_i) {
|
|||
if (pa_atol(s, &l) < 0)
|
||||
return -1;
|
||||
|
||||
if ((int32_t) l != l) {
|
||||
if (l < INT32_MIN || l > INT32_MAX) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2233,7 +2233,7 @@ int pa_atou(const char *s, uint32_t *ret_u) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((uint32_t) l != l) {
|
||||
if (l > UINT32_MAX) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2277,7 +2277,7 @@ int pa_atou64(const char *s, uint64_t *ret_u) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((uint64_t) l != l) {
|
||||
if (l > UINT64_MAX) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -2360,7 +2360,7 @@ int pa_atoi64(const char *s, int64_t *ret_l) {
|
|||
|
||||
*ret_l = l;
|
||||
|
||||
if ((int64_t) l != l) {
|
||||
if (l < INT64_MIN || l > INT64_MAX) {
|
||||
errno = ERANGE;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue