json-c: cast INT64_MAX to double. from upstream
d0b87ee87b
.patch
Subject: [PATCH] Add an explicit cast to double to squash a
-Wimplicit-int-float-conversion warning. Though we will no longer be
comparing exactly against INT64_MAX, this is ok because any value of that
magnitude stored in a double will *also* have been rounded up, so the
comparison will work appropriately.
This commit is contained in:
parent
95708dc482
commit
2dcc8bd71d
@ -1,8 +1,9 @@
|
||||
# $OpenBSD: Makefile,v 1.20 2019/07/12 20:44:36 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.21 2020/07/31 12:13:28 sthen Exp $
|
||||
|
||||
COMMENT= JSON implementation in C
|
||||
|
||||
DISTNAME= json-c-0.13.1
|
||||
REVISION= 0
|
||||
CATEGORIES= devel
|
||||
|
||||
SHARED_LIBS= json-c 1.1 # 4.0
|
||||
|
25
devel/json-c/patches/patch-json_object_c
Normal file
25
devel/json-c/patches/patch-json_object_c
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-json_object_c,v 1.1 2020/07/31 12:13:28 sthen Exp $
|
||||
|
||||
From d0b87ee87b282e9b91a1af924050e217b0b2ae8b Mon Sep 17 00:00:00 2001
|
||||
From: Eric Haszlakiewicz <erh+git@nimenees.com>
|
||||
Date: Mon, 12 Aug 2019 00:30:45 +0000
|
||||
Subject: [PATCH] Add an explicit cast to double to squash a
|
||||
-Wimplicit-int-float-conversion warning. Though we will no longer be
|
||||
comparing exactly against INT64_MAX, this is ok because any value of that
|
||||
magnitude stored in a double will *also* have been rounded up, so the
|
||||
comparison will work appropriately.
|
||||
|
||||
Index: json_object.c
|
||||
--- json_object.c.orig
|
||||
+++ json_object.c
|
||||
@@ -698,7 +698,9 @@ int64_t json_object_get_int64(const struct json_object
|
||||
case json_type_int:
|
||||
return jso->o.c_int64;
|
||||
case json_type_double:
|
||||
- if (jso->o.c_double >= INT64_MAX)
|
||||
+ // INT64_MAX can't be exactly represented as a double
|
||||
+ // so cast to tell the compiler it's ok to round up.
|
||||
+ if (jso->o.c_double >= (double)INT64_MAX)
|
||||
return INT64_MAX;
|
||||
if (jso->o.c_double <= INT64_MIN)
|
||||
return INT64_MIN;
|
Loading…
Reference in New Issue
Block a user