From: Bruce Cran <bruce@cran.org.uk>
To: fio@vger.kernel.org
Subject: io_bytes overflow in JSON output on Windows
Date: Thu, 03 Apr 2014 12:19:50 -0600 [thread overview]
Message-ID: <533DA646.9070807@cran.org.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 252 bytes --]
On Windows, the io_bytes parameter can overflow in the JSON output
because the JSON_INTEGER type is a 'long' - which is only 32-bit on
Windows. The attached patch should fix it by changing the JSON integer
type to be 'long long'.
--
Bruce Cran
[-- Attachment #2: 0001-Fix-JSON_INTEGER-overflow-on-Windows-by-changing-dat.patch --]
[-- Type: text/plain, Size: 2291 bytes --]
From 819255df8c084d9d05e5fcb67ba2620e581cd3e0 Mon Sep 17 00:00:00 2001
From: Bruce Cran <bcran@fusionio.com>
Date: Thu, 3 Apr 2014 12:17:00 -0600
Subject: [PATCH] Fix JSON_INTEGER overflow on Windows by changing datatype to
'long long'
---
json.c | 8 ++++----
json.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/json.c b/json.c
index cba370a..7480a61 100644
--- a/json.c
+++ b/json.c
@@ -35,7 +35,7 @@ static struct json_pair *json_create_pair(const char *name, struct json_value *v
return pair;
}
-static struct json_value *json_create_value_int(long number)
+static struct json_value *json_create_value_int(long long number)
{
struct json_value *value = malloc(sizeof(struct json_value));
@@ -212,7 +212,7 @@ int json_object_add_value_type(struct json_object *obj, const char *name, int ty
if (type == JSON_TYPE_STRING)
value = json_create_value_string(va_arg(args, char *));
else if (type == JSON_TYPE_INTEGER)
- value = json_create_value_int(va_arg(args, long));
+ value = json_create_value_int(va_arg(args, long long));
else if (type == JSON_TYPE_FLOAT)
value = json_create_value_float(va_arg(args, double));
else if (type == JSON_TYPE_OBJECT)
@@ -248,7 +248,7 @@ int json_array_add_value_type(struct json_array *array, int type, ...)
if (type == JSON_TYPE_STRING)
value = json_create_value_string(va_arg(args, char *));
else if (type == JSON_TYPE_INTEGER)
- value = json_create_value_int(va_arg(args, long));
+ value = json_create_value_int(va_arg(args, long long));
else if (type == JSON_TYPE_FLOAT)
value = json_create_value_float(va_arg(args, double));
else if (type == JSON_TYPE_OBJECT)
@@ -350,7 +350,7 @@ static void json_print_value(struct json_value *value)
log_info("\"%s\"", value->string);
break;
case JSON_TYPE_INTEGER:
- log_info("%ld", value->integer_number);
+ log_info("%lld", value->integer_number);
break;
case JSON_TYPE_FLOAT:
log_info("%.2f", value->float_number);
diff --git a/json.h b/json.h
index 2a798ce..081afd6 100644
--- a/json.h
+++ b/json.h
@@ -14,7 +14,7 @@ struct json_pair;
struct json_value {
int type;
union {
- long integer_number;
+ long long integer_number;
double float_number;
char *string;
struct json_object *object;
--
1.9.0.msysgit.0
next reply other threads:[~2014-04-03 18:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 18:19 Bruce Cran [this message]
2014-04-03 18:22 ` io_bytes overflow in JSON output on Windows Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=533DA646.9070807@cran.org.uk \
--to=bruce@cran.org.uk \
--cc=fio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox