mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
json: improve infinite checks
Avoid compiler errors like this: /usr/include/spa-0.2/spa/utils/json.h:417:25: error: comparing floating-point with '==' or '!=' is unsafe [-Werror=float-equal] | 417 | if (val == INFINITY) | | ^~
This commit is contained in:
parent
41b5c50c86
commit
cdb3c64753
1 changed files with 2 additions and 4 deletions
|
|
@ -457,10 +457,8 @@ static inline int spa_json_get_float(struct spa_json *iter, float *res)
|
|||
static inline char *spa_json_format_float(char *str, int size, float val)
|
||||
{
|
||||
if (SPA_UNLIKELY(!isnormal(val))) {
|
||||
if (val == INFINITY)
|
||||
val = FLT_MAX;
|
||||
else if (val == -INFINITY)
|
||||
val = FLT_MIN;
|
||||
if (isinf(val))
|
||||
val = signbit(val) ? FLT_MIN : FLT_MAX;
|
||||
else
|
||||
val = 0.0f;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue