mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
json: improve infinite checks
Avoid compiler errors like this: /usr/include/spa-0.2/spa/utils/json-core.h:417:25: error: comparing floating-point with '==' or '!=' is unsafe [-Werror=float-equal] | 417 | if (val == INFINITY) | | ^~
This commit is contained in:
parent
c3e5371053
commit
7906dc854a
1 changed files with 2 additions and 4 deletions
|
|
@ -414,10 +414,8 @@ static inline bool spa_json_is_float(const char *val, int len)
|
|||
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