summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEvan Green <evgreen@chromium.org>2019-09-23 12:57:40 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-05 00:47:45 +0000
commit3564b23531fc1814924f39e7ac97751d758c14db (patch)
tree39a04f30177288afe594f0d2a22a434a4a5b00f6 /test
parente34fca3e01d75552ad8d712879c3ccd6a6168584 (diff)
downloadchrome-ec-3564b23531fc1814924f39e7ac97751d758c14db.tar.gz
printf: Add support for %z
When printing size_t sized integers, utilize the standard %z modifier so that the specifier format is correct. This will enable us to turn on compile-time printf format verification. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Cq-Depend:chrome-internal:1860160 Change-Id: I2c95df5c0d87677cb9fcbde33ab8846708a774a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819651 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/nvmem.c16
-rw-r--r--test/nvmem_tpm2_mock.c2
-rw-r--r--test/pinweaver.c2
-rw-r--r--test/printf.c2
4 files changed, 11 insertions, 11 deletions
diff --git a/test/nvmem.c b/test/nvmem.c
index 8eaad92f23..303263e614 100644
--- a/test/nvmem.c
+++ b/test/nvmem.c
@@ -119,8 +119,8 @@ static void dump_nvmem_state(const char *title,
ccprintf("deleted_obj_count: %d\n", tr->deleted_obj_count);
ccprintf("deimiter_count: %d\n", tr->delimiter_count);
ccprintf("unexpected_count: %d\n", tr->unexpected_count);
- ccprintf("valid_data_size: %d\n", tr->valid_data_size);
- ccprintf("erased_data_size: %d\n\n", tr->erased_data_size);
+ ccprintf("valid_data_size: %zd\n", tr->valid_data_size);
+ ccprintf("erased_data_size: %zd\n\n", tr->erased_data_size);
}
static void wipe_out_nvmem_cache(void)
@@ -398,7 +398,7 @@ static size_t get_free_nvmem_room(void)
free_room = (free_pages - 1) * (CONFIG_FLASH_BANK_SIZE -
sizeof(struct nn_page_header)) +
CONFIG_FLASH_BANK_SIZE - master_at.mt.data_offset;
- ccprintf("free pages %d, data offset 0x%x\n", free_pages,
+ ccprintf("free pages %zd, data offset 0x%x\n", free_pages,
master_at.mt.data_offset);
return free_room;
}
@@ -649,12 +649,12 @@ static size_t fill_obj_offsets(uint16_t *offsets, size_t max_objects)
obj_count = init_object_offsets(offsets, max_objects);
- ccprintf("%d objects\n", obj_count);
+ ccprintf("%zd objects\n", obj_count);
for (i = 0; i < obj_count; i++) {
uint32_t *op;
op = evictable_offs_to_addr(offsets[i]);
- ccprintf("offs %04x:%08x:%08x:%08x addr %pP size %d\n",
+ ccprintf("offs %04x:%08x:%08x:%08x addr %pP size %zd\n",
offsets[i], op[-1], op[0], op[1], op,
(uintptr_t)nvmem_cache_base(NVMEM_TPM) + op[-1] -
(uintptr_t)op);
@@ -767,7 +767,7 @@ static int caches_match(const uint8_t *cache1, const uint8_t *cache2)
if (!memcmp(cache1 + offset, cache2 + offset, size))
continue;
- ccprintf("%s:%d failed comparing %d:%d:\n", __func__,
+ ccprintf("%s:%d failed comparing %zd:%zd:\n", __func__,
__LINE__, i, j);
for (k = offset; k < (offset + size); k++)
if (cache1[k] != cache2[k])
@@ -1248,7 +1248,7 @@ static int compare_object(uint16_t obj_offset, size_t obj_size, const void *obj)
evictable_offs_to_addr(obj_offset - sizeof(next_addr)),
sizeof(next_addr));
- ccprintf("next_addr %x, sum %x size %d\n", next_addr,
+ ccprintf("next_addr %x, sum %zx size %zd\n", next_addr,
(s_evictNvStart + obj_offset + obj_size), obj_size);
TEST_ASSERT(next_addr == (s_evictNvStart + obj_offset + obj_size));
@@ -1289,7 +1289,7 @@ static int test_tpm_nvmem_modify_evictable_objects(void)
for (i = 0; i < num_objects; i++) {
memcpy(handles + i, evictable_offs_to_addr(offsets[i]),
sizeof(handles[i]));
- ccprintf("obj %d handle %08x\n", i, handles[i]);
+ ccprintf("obj %zd handle %08x\n", i, handles[i]);
}
/*
* Let's modify the object which currently is stored second in the
diff --git a/test/nvmem_tpm2_mock.c b/test/nvmem_tpm2_mock.c
index 3b2e5340ad..a6d32bcb34 100644
--- a/test/nvmem_tpm2_mock.c
+++ b/test/nvmem_tpm2_mock.c
@@ -302,7 +302,7 @@ size_t add_evictable_obj(void *obj, size_t obj_size)
next_addr = end_addr + sizeof(uint32_t) + obj_size;
if (next_addr >= s_evictNvEnd) {
- ccprintf("%s: could not fit %d bytes!\n", __func__, obj_size);
+ ccprintf("%s: could not fit %zd bytes!\n", __func__, obj_size);
return 0;
}
diff --git a/test/pinweaver.c b/test/pinweaver.c
index 093443e49e..63a7e2e067 100644
--- a/test/pinweaver.c
+++ b/test/pinweaver.c
@@ -986,7 +986,7 @@ static int check_dcrypto_mutex_usage(void)
{
if (MOCK_DECRYPTO_init_counter == MOCK_DECRYPTO_release_counter)
return EC_SUCCESS;
- ccprintf("ASSERTION failed: DCRYPTO init(%d) != DCRYPTO release(%d)\n",
+ ccprintf("ASSERTION failed: DCRYPTO init(%zd) != DCRYPTO release(%zd)\n",
MOCK_DECRYPTO_init_counter, MOCK_DECRYPTO_release_counter);
return EC_ERROR_UNKNOWN;
}
diff --git a/test/printf.c b/test/printf.c
index 97bb00c4be..28a78ca973 100644
--- a/test/printf.c
+++ b/test/printf.c
@@ -26,7 +26,7 @@ int run(int expect_ret, const char *expect,
int rv;
ccprintf("\n");
- ccprintf("size_limit=%-4d | format='%s'\n", size_limit, format);
+ ccprintf("size_limit=%-4zd | format='%s'\n", size_limit, format);
ccprintf("expect ='%s' | expect_status=%d\n",
expect ? expect : "NO_BYTES_TOUCHED", expect_ret);