Fix more MinGW build warnings.

This commit is contained in:
Jason Evans 2015-07-17 18:12:44 -07:00
parent f2bc85298c
commit 218b15cc29
4 changed files with 46 additions and 43 deletions

View File

@ -133,30 +133,30 @@
<=, "ju", __VA_ARGS__) <=, "ju", __VA_ARGS__)
#define assert_zd_eq(a, b, ...) assert_cmp(ssize_t, a, b, ==, \ #define assert_zd_eq(a, b, ...) assert_cmp(ssize_t, a, b, ==, \
!=, "zd", __VA_ARGS__) !=, PRIzd, __VA_ARGS__)
#define assert_zd_ne(a, b, ...) assert_cmp(ssize_t, a, b, !=, \ #define assert_zd_ne(a, b, ...) assert_cmp(ssize_t, a, b, !=, \
==, "zd", __VA_ARGS__) ==, PRIzd, __VA_ARGS__)
#define assert_zd_lt(a, b, ...) assert_cmp(ssize_t, a, b, <, \ #define assert_zd_lt(a, b, ...) assert_cmp(ssize_t, a, b, <, \
>=, "zd", __VA_ARGS__) >=, PRIzd, __VA_ARGS__)
#define assert_zd_le(a, b, ...) assert_cmp(ssize_t, a, b, <=, \ #define assert_zd_le(a, b, ...) assert_cmp(ssize_t, a, b, <=, \
>, "zd", __VA_ARGS__) >, PRIzd, __VA_ARGS__)
#define assert_zd_ge(a, b, ...) assert_cmp(ssize_t, a, b, >=, \ #define assert_zd_ge(a, b, ...) assert_cmp(ssize_t, a, b, >=, \
<, "zd", __VA_ARGS__) <, PRIzd, __VA_ARGS__)
#define assert_zd_gt(a, b, ...) assert_cmp(ssize_t, a, b, >, \ #define assert_zd_gt(a, b, ...) assert_cmp(ssize_t, a, b, >, \
<=, "zd", __VA_ARGS__) <=, PRIzd, __VA_ARGS__)
#define assert_zu_eq(a, b, ...) assert_cmp(size_t, a, b, ==, \ #define assert_zu_eq(a, b, ...) assert_cmp(size_t, a, b, ==, \
!=, "zu", __VA_ARGS__) !=, PRIzu, __VA_ARGS__)
#define assert_zu_ne(a, b, ...) assert_cmp(size_t, a, b, !=, \ #define assert_zu_ne(a, b, ...) assert_cmp(size_t, a, b, !=, \
==, "zu", __VA_ARGS__) ==, PRIzu, __VA_ARGS__)
#define assert_zu_lt(a, b, ...) assert_cmp(size_t, a, b, <, \ #define assert_zu_lt(a, b, ...) assert_cmp(size_t, a, b, <, \
>=, "zu", __VA_ARGS__) >=, PRIzu, __VA_ARGS__)
#define assert_zu_le(a, b, ...) assert_cmp(size_t, a, b, <=, \ #define assert_zu_le(a, b, ...) assert_cmp(size_t, a, b, <=, \
>, "zu", __VA_ARGS__) >, PRIzu, __VA_ARGS__)
#define assert_zu_ge(a, b, ...) assert_cmp(size_t, a, b, >=, \ #define assert_zu_ge(a, b, ...) assert_cmp(size_t, a, b, >=, \
<, "zu", __VA_ARGS__) <, PRIzu, __VA_ARGS__)
#define assert_zu_gt(a, b, ...) assert_cmp(size_t, a, b, >, \ #define assert_zu_gt(a, b, ...) assert_cmp(size_t, a, b, >, \
<=, "zu", __VA_ARGS__) <=, PRIzu, __VA_ARGS__)
#define assert_d32_eq(a, b, ...) assert_cmp(int32_t, a, b, ==, \ #define assert_d32_eq(a, b, ...) assert_cmp(int32_t, a, b, ==, \
!=, PRId32, __VA_ARGS__) !=, PRId32, __VA_ARGS__)

View File

@ -97,7 +97,7 @@ TEST_STRUCT(z, size_t)
TEST_BEGIN(test_atomic_z) TEST_BEGIN(test_atomic_z)
{ {
TEST_BODY(z, size_t, size_t, zu, "#zx"); TEST_BODY(z, size_t, size_t, zu, "#"PRIzx);
} }
TEST_END TEST_END

View File

@ -35,15 +35,15 @@ TEST_BEGIN(test_count_insert_search_remove)
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp), assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
"Unexpected ckh_new() error"); "Unexpected ckh_new() error");
assert_zu_eq(ckh_count(&ckh), 0, assert_zu_eq(ckh_count(&ckh), 0,
"ckh_count() should return %zu, but it returned %zu", ZU(0), "ckh_count() should return %"PRIzu", but it returned %"PRIzu, ZU(0),
ckh_count(&ckh)); ckh_count(&ckh));
/* Insert. */ /* Insert. */
for (i = 0; i < sizeof(strs)/sizeof(const char *); i++) { for (i = 0; i < sizeof(strs)/sizeof(const char *); i++) {
ckh_insert(tsd, &ckh, strs[i], strs[i]); ckh_insert(tsd, &ckh, strs[i], strs[i]);
assert_zu_eq(ckh_count(&ckh), i+1, assert_zu_eq(ckh_count(&ckh), i+1,
"ckh_count() should return %zu, but it returned %zu", i+1, "ckh_count() should return %"PRIzu", but it returned "
ckh_count(&ckh)); "%"PRIzu, i+1, ckh_count(&ckh));
} }
/* Search. */ /* Search. */
@ -65,9 +65,9 @@ TEST_BEGIN(test_count_insert_search_remove)
ks = (i & 1) ? strs[i] : (const char *)NULL; ks = (i & 1) ? strs[i] : (const char *)NULL;
vs = (i & 2) ? strs[i] : (const char *)NULL; vs = (i & 2) ? strs[i] : (const char *)NULL;
assert_ptr_eq((void *)ks, (void *)k.s, assert_ptr_eq((void *)ks, (void *)k.s,
"Key mismatch, i=%zu", i); "Key mismatch, i=%"PRIzu, i);
assert_ptr_eq((void *)vs, (void *)v.s, assert_ptr_eq((void *)vs, (void *)v.s,
"Value mismatch, i=%zu", i); "Value mismatch, i=%"PRIzu, i);
} }
assert_true(ckh_search(&ckh, missing, NULL, NULL), assert_true(ckh_search(&ckh, missing, NULL, NULL),
"Unexpected ckh_search() success"); "Unexpected ckh_search() success");
@ -91,13 +91,13 @@ TEST_BEGIN(test_count_insert_search_remove)
ks = (i & 1) ? strs[i] : (const char *)NULL; ks = (i & 1) ? strs[i] : (const char *)NULL;
vs = (i & 2) ? strs[i] : (const char *)NULL; vs = (i & 2) ? strs[i] : (const char *)NULL;
assert_ptr_eq((void *)ks, (void *)k.s, assert_ptr_eq((void *)ks, (void *)k.s,
"Key mismatch, i=%zu", i); "Key mismatch, i=%"PRIzu, i);
assert_ptr_eq((void *)vs, (void *)v.s, assert_ptr_eq((void *)vs, (void *)v.s,
"Value mismatch, i=%zu", i); "Value mismatch, i=%"PRIzu, i);
assert_zu_eq(ckh_count(&ckh), assert_zu_eq(ckh_count(&ckh),
sizeof(strs)/sizeof(const char *) - i - 1, sizeof(strs)/sizeof(const char *) - i - 1,
"ckh_count() should return %zu, but it returned %zu", "ckh_count() should return %"PRIzu", but it returned "
sizeof(strs)/sizeof(const char *) - i - 1, "%"PRIzu, sizeof(strs)/sizeof(const char *) - i - 1,
ckh_count(&ckh)); ckh_count(&ckh));
} }
@ -137,8 +137,8 @@ TEST_BEGIN(test_insert_iter_remove)
} }
assert_zu_eq(ckh_count(&ckh), NITEMS, assert_zu_eq(ckh_count(&ckh), NITEMS,
"ckh_count() should return %zu, but it returned %zu", "ckh_count() should return %"PRIzu", but it returned "
NITEMS, ckh_count(&ckh)); "%"PRIzu, NITEMS, ckh_count(&ckh));
for (j = i + 1; j < NITEMS; j++) { for (j = i + 1; j < NITEMS; j++) {
assert_false(ckh_search(&ckh, p[j], NULL, NULL), assert_false(ckh_search(&ckh, p[j], NULL, NULL),
@ -167,17 +167,20 @@ TEST_BEGIN(test_insert_iter_remove)
for (k = 0; k < NITEMS; k++) { for (k = 0; k < NITEMS; k++) {
if (p[k] == q) { if (p[k] == q) {
assert_false(seen[k], assert_false(seen[k],
"Item %zu already seen", k); "Item %"PRIzu" already "
"seen", k);
seen[k] = true; seen[k] = true;
break; break;
} }
} }
} }
for (j = 0; j < i + 1; j++) for (j = 0; j < i + 1; j++) {
assert_true(seen[j], "Item %zu not seen", j); assert_true(seen[j], "Item %"PRIzu" not seen",
j);
}
for (; j < NITEMS; j++) for (; j < NITEMS; j++)
assert_false(seen[j], "Item %zu seen", j); assert_false(seen[j], "Item %"PRIzu" seen", j);
} }
} }
@ -196,8 +199,8 @@ TEST_BEGIN(test_insert_iter_remove)
} }
assert_zu_eq(ckh_count(&ckh), 0, assert_zu_eq(ckh_count(&ckh), 0,
"ckh_count() should return %zu, but it returned %zu", ZU(0), "ckh_count() should return %"PRIzu", but it returned %"PRIzu,
ckh_count(&ckh)); ZU(0), ckh_count(&ckh));
ckh_delete(tsd, &ckh); ckh_delete(tsd, &ckh);
#undef NITEMS #undef NITEMS
} }

View File

@ -30,8 +30,8 @@ arena_dalloc_junk_small_intercept(void *ptr, arena_bin_info_t *bin_info)
arena_dalloc_junk_small_orig(ptr, bin_info); arena_dalloc_junk_small_orig(ptr, bin_info);
for (i = 0; i < bin_info->reg_size; i++) { for (i = 0; i < bin_info->reg_size; i++) {
assert_c_eq(((char *)ptr)[i], 0x5a, assert_c_eq(((char *)ptr)[i], 0x5a,
"Missing junk fill for byte %zu/%zu of deallocated region", "Missing junk fill for byte %"PRIzu"/%"PRIzu" of "
i, bin_info->reg_size); "deallocated region", i, bin_info->reg_size);
} }
if (ptr == watch_for_junking) if (ptr == watch_for_junking)
saw_junking = true; saw_junking = true;
@ -45,8 +45,8 @@ arena_dalloc_junk_large_intercept(void *ptr, size_t usize)
arena_dalloc_junk_large_orig(ptr, usize); arena_dalloc_junk_large_orig(ptr, usize);
for (i = 0; i < usize; i++) { for (i = 0; i < usize; i++) {
assert_c_eq(((char *)ptr)[i], 0x5a, assert_c_eq(((char *)ptr)[i], 0x5a,
"Missing junk fill for byte %zu/%zu of deallocated region", "Missing junk fill for byte %"PRIzu"/%"PRIzu" of "
i, usize); "deallocated region", i, usize);
} }
if (ptr == watch_for_junking) if (ptr == watch_for_junking)
saw_junking = true; saw_junking = true;
@ -89,18 +89,18 @@ test_junk(size_t sz_min, size_t sz_max)
sz_prev = sz, sz = sallocx(s, 0)) { sz_prev = sz, sz = sallocx(s, 0)) {
if (sz_prev > 0) { if (sz_prev > 0) {
assert_c_eq(s[0], 'a', assert_c_eq(s[0], 'a',
"Previously allocated byte %zu/%zu is corrupted", "Previously allocated byte %"PRIzu"/%"PRIzu" is "
ZU(0), sz_prev); "corrupted", ZU(0), sz_prev);
assert_c_eq(s[sz_prev-1], 'a', assert_c_eq(s[sz_prev-1], 'a',
"Previously allocated byte %zu/%zu is corrupted", "Previously allocated byte %"PRIzu"/%"PRIzu" is "
sz_prev-1, sz_prev); "corrupted", sz_prev-1, sz_prev);
} }
for (i = sz_prev; i < sz; i++) { for (i = sz_prev; i < sz; i++) {
if (opt_junk_alloc) { if (opt_junk_alloc) {
assert_c_eq(s[i], 0xa5, assert_c_eq(s[i], 0xa5,
"Newly allocated byte %zu/%zu isn't " "Newly allocated byte %"PRIzu"/%"PRIzu
"junk-filled", i, sz); " isn't junk-filled", i, sz);
} }
s[i] = 'a'; s[i] = 'a';
} }
@ -111,15 +111,15 @@ test_junk(size_t sz_min, size_t sz_max)
assert_ptr_not_null((void *)s, assert_ptr_not_null((void *)s,
"Unexpected rallocx() failure"); "Unexpected rallocx() failure");
assert_true(!opt_junk_free || saw_junking, assert_true(!opt_junk_free || saw_junking,
"Expected region of size %zu to be junk-filled", "Expected region of size %"PRIzu" to be "
sz); "junk-filled", sz);
} }
} }
watch_junking(s); watch_junking(s);
dallocx(s, 0); dallocx(s, 0);
assert_true(!opt_junk_free || saw_junking, assert_true(!opt_junk_free || saw_junking,
"Expected region of size %zu to be junk-filled", sz); "Expected region of size %"PRIzu" to be junk-filled", sz);
if (opt_junk_free) { if (opt_junk_free) {
arena_dalloc_junk_small = arena_dalloc_junk_small_orig; arena_dalloc_junk_small = arena_dalloc_junk_small_orig;