summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-02-26 00:40:24 (GMT)
committerJason Evans <jasone@canonware.com>2016-02-26 00:40:24 (GMT)
commite3195fa4a54344cf707d30e510e91ed43f5a8b84 (patch)
tree3c25f3e069e3debbec1381ad3513cc99f36d4be1
parent0c516a00c4cb28cff55ce0995f756b5aae074c9e (diff)
downloadjemalloc-e3195fa4a54344cf707d30e510e91ed43f5a8b84.zip
jemalloc-e3195fa4a54344cf707d30e510e91ed43f5a8b84.tar.gz
jemalloc-e3195fa4a54344cf707d30e510e91ed43f5a8b84.tar.bz2
Cast PTRDIFF_MAX to size_t before adding 1.
This fixes compilation warnings regarding integer overflow that were introduced by 0c516a00c4cb28cff55ce0995f756b5aae074c9e (Make *allocx() size class overflow behavior defined.).
-rw-r--r--test/integration/mallocx.c8
-rw-r--r--test/integration/rallocx.c8
-rw-r--r--test/unit/size_classes.c4
3 files changed, 10 insertions, 10 deletions
diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c
index 35c559a..6ecd636 100644
--- a/test/integration/mallocx.c
+++ b/test/integration/mallocx.c
@@ -55,8 +55,8 @@ TEST_BEGIN(test_overflow)
assert_ptr_null(mallocx(hugemax+1, 0),
"Expected OOM for mallocx(size=%#zx, 0)", hugemax+1);
- assert_ptr_null(mallocx(PTRDIFF_MAX+1, 0),
- "Expected OOM for mallocx(size=%#zx, 0)", ZU(PTRDIFF_MAX+1));
+ assert_ptr_null(mallocx(ZU(PTRDIFF_MAX)+1, 0),
+ "Expected OOM for mallocx(size=%#zx, 0)", ZU(PTRDIFF_MAX)+1);
assert_ptr_null(mallocx(SIZE_T_MAX, 0),
"Expected OOM for mallocx(size=%#zx, 0)", SIZE_T_MAX);
@@ -69,9 +69,9 @@ TEST_BEGIN(test_overflow)
assert_ptr_null(mallocx(size, 0),
"Expected OOM for mallocx(size=%#zx, 0", size);
- assert_ptr_null(mallocx(1, MALLOCX_ALIGN(PTRDIFF_MAX+1)),
+ assert_ptr_null(mallocx(1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
"Expected OOM for mallocx(size=1, MALLOCX_ALIGN(%#zx))",
- ZU(PTRDIFF_MAX+1));
+ ZU(PTRDIFF_MAX)+1);
}
TEST_END
diff --git a/test/integration/rallocx.c b/test/integration/rallocx.c
index 3b7d21c..c3c2241 100644
--- a/test/integration/rallocx.c
+++ b/test/integration/rallocx.c
@@ -232,8 +232,8 @@ TEST_BEGIN(test_overflow)
assert_ptr_null(rallocx(p, hugemax+1, 0),
"Expected OOM for rallocx(p, size=%#zx, 0)", hugemax+1);
- assert_ptr_null(rallocx(p, PTRDIFF_MAX+1, 0),
- "Expected OOM for rallocx(p, size=%#zx, 0)", ZU(PTRDIFF_MAX+1));
+ assert_ptr_null(rallocx(p, ZU(PTRDIFF_MAX)+1, 0),
+ "Expected OOM for rallocx(p, size=%#zx, 0)", ZU(PTRDIFF_MAX)+1);
assert_ptr_null(rallocx(p, SIZE_T_MAX, 0),
"Expected OOM for rallocx(p, size=%#zx, 0)", SIZE_T_MAX);
@@ -246,9 +246,9 @@ TEST_BEGIN(test_overflow)
assert_ptr_null(rallocx(p, size, 0),
"Expected OOM for rallocx(p, size=%#zx, 0", size);
- assert_ptr_null(rallocx(p, 1, MALLOCX_ALIGN(PTRDIFF_MAX+1)),
+ assert_ptr_null(rallocx(p, 1, MALLOCX_ALIGN(ZU(PTRDIFF_MAX)+1)),
"Expected OOM for rallocx(p, size=1, MALLOCX_ALIGN(%#zx))",
- ZU(PTRDIFF_MAX+1));
+ ZU(PTRDIFF_MAX)+1);
dallocx(p, 0);
}
diff --git a/test/unit/size_classes.c b/test/unit/size_classes.c
index 3a2126f..2e2caaf 100644
--- a/test/unit/size_classes.c
+++ b/test/unit/size_classes.c
@@ -88,14 +88,14 @@ TEST_BEGIN(test_overflow)
assert_u_ge(size2index(max_size_class+1), NSIZES,
"size2index() should return >= NSIZES on overflow");
- assert_u_ge(size2index(PTRDIFF_MAX+1), NSIZES,
+ assert_u_ge(size2index(ZU(PTRDIFF_MAX)+1), NSIZES,
"size2index() should return >= NSIZES on overflow");
assert_u_ge(size2index(SIZE_T_MAX), NSIZES,
"size2index() should return >= NSIZES on overflow");
assert_zu_gt(s2u(max_size_class+1), HUGE_MAXCLASS,
"s2u() should return > HUGE_MAXCLASS for unsupported size");
- assert_zu_gt(s2u(PTRDIFF_MAX+1), HUGE_MAXCLASS,
+ assert_zu_gt(s2u(ZU(PTRDIFF_MAX)+1), HUGE_MAXCLASS,
"s2u() should return > HUGE_MAXCLASS for unsupported size");
assert_zu_eq(s2u(SIZE_T_MAX), 0,
"s2u() should return 0 on overflow");