Welcome! Log In Create A New Profile

Advanced

[njs] Fixed implicit long to double conversion warning.

Dmitry Volyntsev
May 24, 2021 08:36AM
details: https://hg.nginx.org/njs/rev/98f436565ddf
branches:
changeset: 1641:98f436565ddf
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Mon May 24 12:33:43 2021 +0000
description:
Fixed implicit long to double conversion warning.

error: implicit conversion from 'long' to 'double' changes value from
9223372036854775807 to 9223372036854775808.

diffstat:

src/njs_number.h | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 55d405b30979 -r 98f436565ddf src/njs_number.h
--- a/src/njs_number.h Mon May 24 12:33:36 2021 +0000
+++ b/src/njs_number.h Mon May 24 12:33:43 2021 +0000
@@ -8,7 +8,9 @@
#define _NJS_NUMBER_H_INCLUDED_


-#define NJS_MAX_LENGTH (0x1fffffffffffffLL)
+#define NJS_MAX_LENGTH (0x1fffffffffffffLL)
+#define NJS_INT64_DBL_MIN (-9.223372036854776e+18) /* closest to INT64_MIN */
+#define NJS_INT64_DBL_MAX (9.223372036854776e+18) /* closest to INT64_MAX */


double njs_key_to_index(const njs_value_t *value);
@@ -57,10 +59,10 @@ njs_inline int64_t
njs_number_to_integer(double num)
{
if (njs_fast_path(!isnan(num))) {
- if (num < INT64_MIN) {
+ if (num < NJS_INT64_DBL_MIN) {
return INT64_MIN;

- } else if (num > INT64_MAX) {
+ } else if (num > NJS_INT64_DBL_MAX) {
return INT64_MAX;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed implicit long to double conversion warning.

Dmitry Volyntsev 98 May 24, 2021 08:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready