[njs] Fixed implicit long to double conversion warning.

Dmitry Volyntsev xeioex at nginx.com
Mon May 24 12:35:29 UTC 2021


details:   https://hg.nginx.org/njs/rev/98f436565ddf
branches:  
changeset: 1641:98f436565ddf
user:      Dmitry Volyntsev <xeioex at 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;
         }
 


More information about the nginx-devel mailing list