[njs] Fixed compilation on 32bit platforms.

noreply at nginx.com noreply at nginx.com
Fri Aug 16 15:27:02 UTC 2024


details:   https://github.com/nginx/njs/commit/598fc578fcba772dc3649f74f1cbef7f5783961f
branches:  master
commit:    598fc578fcba772dc3649f74f1cbef7f5783961f
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu, 15 Aug 2024 22:02:48 -0700
description:
Fixed compilation on 32bit platforms.

The issue was introduced in d1c615eaa.

---
 src/qjs.h        |  1 +
 src/qjs_buffer.c | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/qjs.h b/src/qjs.h
index 00e9296a..f8eabefa 100644
--- a/src/qjs.h
+++ b/src/qjs.h
@@ -11,6 +11,7 @@
 
 #include <njs_types.h>
 #include <njs_clang.h>
+#include <inttypes.h>
 #include <string.h>
 #include <njs_str.h>
 #include <njs_unicode.h>
diff --git a/src/qjs_buffer.c b/src/qjs_buffer.c
index 83764e02..06574110 100644
--- a/src/qjs_buffer.c
+++ b/src/qjs_buffer.c
@@ -760,7 +760,7 @@ qjs_buffer_array_range(JSContext *ctx, njs_str_t *array, JSValueConst start,
     }
 
     if (num_start < 0 || (size_t) num_start > array->length) {
-        return JS_ThrowRangeError(ctx, "\"%sStart\" is out of range: %ld",
+        return JS_ThrowRangeError(ctx, "\"%sStart\" is out of range: %" PRId64,
                                   name, num_start);
     }
 
@@ -773,7 +773,7 @@ qjs_buffer_array_range(JSContext *ctx, njs_str_t *array, JSValueConst start,
     }
 
     if (num_end < 0 || (size_t) num_end > array->length) {
-        return JS_ThrowRangeError(ctx, "\"%sEnd\" is out of range: %ld",
+        return JS_ThrowRangeError(ctx, "\"%sEnd\" is out of range: %" PRId64,
                                   name, num_end);
     }
 
@@ -1141,8 +1141,8 @@ qjs_buffer_prototype_read_float(JSContext *ctx, JSValueConst this_val,
     size = magic >> 2;
 
     if (size + index > self.length) {
-        return JS_ThrowRangeError(ctx, "index %lu is outside the bound of the"
-                                  " buffer", index);
+        return JS_ThrowRangeError(ctx, "index %" PRIu64 " is outside the bound"
+                                  " of the buffer", index);
     }
 
     little = magic & 1;
@@ -1217,8 +1217,8 @@ qjs_buffer_prototype_read_int(JSContext *ctx, JSValueConst this_val,
     }
 
     if (size + index > self.length) {
-        return JS_ThrowRangeError(ctx, "index %lu is outside the bound of the"
-                                  " buffer", index);
+        return JS_ThrowRangeError(ctx, "index %" PRIu64 " is outside the bound"
+                                  " of the buffer", index);
     }
 
     sign = (magic >> 1) & 1;
@@ -1628,8 +1628,8 @@ qjs_buffer_prototype_write_int(JSContext *ctx, JSValueConst this_val,
     }
 
     if (size + index > self.length) {
-        return JS_ThrowRangeError(ctx, "index %lu is outside the bound of the"
-                                  " buffer", index);
+        return JS_ThrowRangeError(ctx, "index %" PRIu64 " is outside the bound"
+                                  " of the buffer", index);
     }
 
     little = magic & 1;
@@ -1834,8 +1834,8 @@ qjs_buffer_prototype_write_float(JSContext *ctx, JSValueConst this_val,
     size = magic >> 2;
 
     if (size + index > self.length) {
-        return JS_ThrowRangeError(ctx, "index %lu is outside the bound of the"
-                                  " buffer", index);
+        return JS_ThrowRangeError(ctx, "index %" PRIu64 " is outside the bound"
+                                  " of the buffer", index);
     }
 
     little = magic & 1;


More information about the nginx-devel mailing list