summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravan Karthik <shravan.karthik@ti.com>2018-10-31 11:09:16 +0530
committerSam Nelson <sam.nelson@ti.com>2018-11-07 07:47:40 -0500
commitc9b758e12f04faa2c7d9ff9868b504c2832d5a33 (patch)
treeb79b1d598b82224ab0f82a84150c8ad136d8cc48
parentba8b6caee354f40176f4a3e3929c153a373ebe54 (diff)
downloadlinuxutils-dev2/lu-next.tar.gz
tests: Cleanup to prevent size mismatch warningsdev2/lu-next
Signed-off-by: Shravan Karthik <shravan.karthik@ti.com> Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r--src/cmem/tests/apitest.c84
-rw-r--r--src/cmem/tests/multi_process.c8
-rw-r--r--src/cmem/tests/translate.c43
3 files changed, 68 insertions, 67 deletions
diff --git a/src/cmem/tests/apitest.c b/src/cmem/tests/apitest.c
index a51a51e..14936af 100644
--- a/src/cmem/tests/apitest.c
+++ b/src/cmem/tests/apitest.c
@@ -332,19 +332,19 @@ void testCache(size_t size, int block)
ptr1_nocache = CMEM_alloc2(block, size, NULL);
if (ptr1_nocache == NULL) {
- fprintf(stderr, "Failed to allocate buffer of size %d\n", size);
+ fprintf(stderr, "Failed to allocate buffer of size 0x%zx\n", size);
goto cleanup;
}
- printf("Allocated buffer of size %d at address %#x.\n", size,
- (unsigned int) ptr1_nocache);
+ printf("Allocated buffer of size 0x%zx at address %p.\n", size,
+ ptr1_nocache);
/* Find out and print the physical address of this buffer */
physp_nocache = CMEM_getPhys(ptr1_nocache);
if (physp_nocache == 0) {
- fprintf(stderr, "Failed to get physical address of buffer %#x\n",
- (unsigned int) ptr1_nocache);
+ fprintf(stderr, "Failed to get physical address of buffer %p\n",
+ ptr1_nocache);
goto cleanup;
}
@@ -364,19 +364,19 @@ void testCache(size_t size, int block)
ptr1_cache = CMEM_alloc2(block, size, &params);
if (ptr1_cache == NULL) {
- fprintf(stderr, "Failed to allocate buffer of size %d\n", size);
+ fprintf(stderr, "Failed to allocate buffer of size 0x%zx\n", size);
goto cleanup;
}
- printf("Allocated buffer of size %d at address %#x.\n", size,
- (unsigned int)ptr1_cache);
+ printf("Allocated buffer of size 0x%zx at address %p.\n", size,
+ ptr1_cache);
/* Find out and print the physical address of this buffer */
physp_cache = CMEM_getPhys(ptr1_cache);
if (physp_cache == 0) {
- fprintf(stderr, "Failed to get physical address of buffer %#x\n",
- (unsigned int)ptr1_cache);
+ fprintf(stderr, "Failed to get physical address of buffer %p\n",
+ ptr1_cache);
goto cleanup;
}
@@ -394,19 +394,19 @@ void testCache(size_t size, int block)
ptr1_dma = CMEM_alloc2(block, size, NULL);
if (ptr1_dma == NULL) {
- fprintf(stderr, "Failed to allocate buffer of size %d\n", size);
+ fprintf(stderr, "Failed to allocate buffer of size 0x%zx\n", size);
goto cleanup;
}
- printf("Allocated buffer of size %d at address %#x.\n", size,
- (unsigned int)ptr1_dma);
+ printf("Allocated buffer of size 0x%zx at address %p.\n", size,
+ ptr1_dma);
/* Find out and print the physical address of this buffer */
physp_dma = CMEM_getPhys(ptr1_dma);
if (physp_dma == 0) {
- fprintf(stderr, "Failed to get physical address of buffer %#x\n",
- (unsigned int)ptr1_dma);
+ fprintf(stderr, "Failed to get physical address of buffer %p\n",
+ ptr1_dma);
goto cleanup;
}
@@ -484,28 +484,28 @@ void testCache(size_t size, int block)
poolid = CMEM_getPool2(block, size);
if (poolid == -1) {
- fprintf(stderr, "Failed to get a pool which fits size %d\n", size);
+ fprintf(stderr, "Failed to get a pool which fits size 0x%zx\n", size);
goto cleanup;
}
- printf("Got a pool (%d) that fits the size %d\n", poolid, size);
+ printf("Got a pool (%d) that fits the size 0x%zx\n", poolid, size);
ptr2 = CMEM_allocPool2(block, poolid, NULL);
if (ptr2 == NULL) {
- fprintf(stderr, "Failed to allocate buffer of size %d\n", size);
+ fprintf(stderr, "Failed to allocate buffer of size 0x%zx\n", size);
goto cleanup;
}
- printf("Allocated buffer of size %d at address %#x.\n", size,
- (unsigned int)ptr2);
+ printf("Allocated buffer of size 0x%zx at address %p.\n", size,
+ ptr2);
/* Find out and print the physical address of this buffer */
physp = CMEM_getPhys(ptr2);
if (physp == 0) {
- fprintf(stderr, "Failed to get physical address of buffer %#x\n",
- (unsigned int)ptr2);
+ fprintf(stderr, "Failed to get physical address of buffer %p\n",
+ ptr2);
goto cleanup;
}
@@ -528,38 +528,38 @@ void testCache(size_t size, int block)
cleanup:
if (ptr1_nocache != NULL) {
if (CMEM_free(ptr1_nocache, NULL) < 0) {
- fprintf(stderr, "Failed to free buffer at %#x\n",
- (unsigned int)ptr1_nocache);
+ fprintf(stderr, "Failed to free buffer at %p\n",
+ ptr1_nocache);
}
- printf("Successfully freed buffer at %#x.\n",
- (unsigned int)ptr1_nocache);
+ printf("Successfully freed buffer at %p.\n",
+ ptr1_nocache);
}
if (ptr1_cache != NULL) {
if (CMEM_free(ptr1_cache, &params) < 0) {
- fprintf(stderr, "Failed to free buffer at %#x\n",
- (unsigned int)ptr1_cache);
+ fprintf(stderr, "Failed to free buffer at %p\n",
+ ptr1_cache);
}
- printf("Successfully freed buffer at %#x.\n",
- (unsigned int)ptr1_cache);
+ printf("Successfully freed buffer at %p.\n",
+ ptr1_cache);
}
if (ptr1_dma != NULL) {
if (CMEM_free(ptr1_dma, NULL) < 0) {
- fprintf(stderr, "Failed to free buffer at %#x\n",
- (unsigned int)ptr1_dma);
+ fprintf(stderr, "Failed to free buffer at %p\n",
+ ptr1_dma);
}
- printf("Successfully freed buffer at %#x.\n",
- (unsigned int)ptr1_dma);
+ printf("Successfully freed buffer at %p.\n",
+ ptr1_dma);
}
if (ptr2 != NULL) {
if (CMEM_free(ptr2, NULL) < 0) {
- fprintf(stderr, "Failed to free buffer at %#x\n",
- (unsigned int)ptr2);
+ fprintf(stderr, "Failed to free buffer at %p\n",
+ ptr2);
}
- printf("Successfully freed buffer at %#x.\n",
- (unsigned int)ptr2);
+ printf("Successfully freed buffer at %p.\n",
+ ptr2);
}
}
@@ -598,7 +598,7 @@ int testMap(size_t size)
goto cleanup;
}
else {
- printf("testMap: remapped physp %#llx to %p\n",
+ printf("testMap: remapped physp %#zx to %p\n",
physp, map_ptr);
printf(" *map_ptr = 0x%x\n", *map_ptr);
}
@@ -619,7 +619,7 @@ int testMap(size_t size)
printf("testMap: original pointer still good\n");
}
- printf("testMap: trying to map too much (0x%x)...\n", size * 0x10);
+ printf("testMap: trying to map too much (0x%zx)...\n", size * 0x10);
#if defined(LINUXUTILS_BUILDOS_ANDROID)
map_ptr = CMEM_map64(physp, size * 0x10);
#else
@@ -664,7 +664,7 @@ int testAllocPhys(size_t size)
goto cleanup;
}
else {
- printf("testAllocPhys: mapped physp %#llx to %p\n",
+ printf("testAllocPhys: mapped physp %#zx to %p\n",
physp, map_ptr);
}
@@ -680,7 +680,7 @@ int testAllocPhys(size_t size)
printf(" unmapping %p\n", map_ptr);
CMEM_unmap(map_ptr, size);
- printf("testAllocPhys: trying to map too much (0x%x)...\n", size * 0x10);
+ printf("testAllocPhys: trying to map too much (0x%zx)...\n", size * 0x10);
#if defined(LINUXUTILS_BUILDOS_ANDROID)
map_ptr = CMEM_map64(physp, size * 0x10);
#else
diff --git a/src/cmem/tests/multi_process.c b/src/cmem/tests/multi_process.c
index 8b14ba3..139e604 100644
--- a/src/cmem/tests/multi_process.c
+++ b/src/cmem/tests/multi_process.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- printf("Process %d: Allocated buffer at %#x\n", pid, (unsigned int) ptr);
+ printf("Process %d: Allocated buffer at %p\n", pid, ptr);
/* Write some data into this buffer */
for (i=0; i < BUFFER_SIZE / sizeof(int) ; i++) {
@@ -123,11 +123,11 @@ int main(int argc, char *argv[])
sleep(r);
if (pid % 2) {
- printf("Process %d: Freeing buffer at %#x\n", pid, (unsigned int) ptr);
+ printf("Process %d: Freeing buffer at %p\n", pid, ptr);
if (CMEM_free(ptr, NULL) < 0) {
- fprintf(stderr, "Process %d: Failed to free buffer at %#x\n",
- pid, (unsigned int) ptr);
+ fprintf(stderr, "Process %d: Failed to free buffer at %p\n",
+ pid, ptr);
}
}
else {
diff --git a/src/cmem/tests/translate.c b/src/cmem/tests/translate.c
index 7ba2568..4c633dc 100644
--- a/src/cmem/tests/translate.c
+++ b/src/cmem/tests/translate.c
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <ti/cmem.h>
@@ -72,8 +73,8 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- printf("Allocated buffer of size %d at virtual address %#x.\n", BUFSIZE,
- (unsigned int) ptr);
+ printf("Allocated buffer of size %d at virtual address %p.\n", BUFSIZE,
+ ptr);
orig = ptr;
@@ -83,13 +84,13 @@ int main(int argc, char *argv[])
physp = CMEM_getPhys(ptr);
if (physp == 0) {
- fprintf(stderr, "Failed to get physical address of %#x\n",
- (unsigned int) ptr);
+ fprintf(stderr, "Failed to get physical address of %p\n",
+ ptr);
goto cleanup;
}
- printf("virtual=%#x physical=%#llx\n", (unsigned int) ptr,
- (unsigned long long) physp);
+ printf("virtual=%p physical=%zx\n", ptr,
+ physp);
ptr += inc;
}
@@ -101,13 +102,13 @@ int main(int argc, char *argv[])
physp = CMEM_getPhys(ptr);
if (physp == 0) {
- fprintf(stderr, "Failed to get physical address of %#x\n",
- (unsigned int) ptr);
+ fprintf(stderr, "Failed to get physical address of %p\n",
+ ptr);
goto cleanup;
}
- printf("virtual=%#x physical=%#llx\n", (unsigned int) ptr,
- (unsigned long long) physp);
+ printf("virtual=%p physical=%zx\n", ptr,
+ physp);
ptr += inc;
}
@@ -119,13 +120,13 @@ int main(int argc, char *argv[])
physp = CMEM_getPhys(ptr);
if (physp == 0) {
- fprintf(stderr, "Failed to get physical address of %#x\n",
- (unsigned int) ptr);
+ fprintf(stderr, "Failed to get physical address of %p\n",
+ ptr);
goto cleanup;
}
- printf("virtual=%#x physical=%#llx\n", (unsigned int) ptr,
- (unsigned long long) physp);
+ printf("virtual=%p physical=%zx\n", ptr,
+ physp);
ptr += inc;
}
@@ -137,13 +138,13 @@ int main(int argc, char *argv[])
physp = CMEM_getPhys(ptr);
if (physp == 0) {
- fprintf(stderr, "Failed to get physical address of %#x\n",
- (unsigned int) ptr);
+ fprintf(stderr, "Failed to get physical address of %p\n",
+ ptr);
goto cleanup;
}
- printf("virtual=%#x physical=%#llx\n", (unsigned int) ptr,
- (unsigned long long) physp);
+ printf("virtual=%p physical=%zx\n", ptr,
+ physp);
ptr += inc;
}
@@ -151,11 +152,11 @@ int main(int argc, char *argv[])
cleanup:
ptr = orig;
if (CMEM_free(ptr, NULL) < 0) {
- fprintf(stderr, "Failed to free buffer at %#x\n",
- (unsigned int) ptr);
+ fprintf(stderr, "Failed to free buffer at %p\n",
+ ptr);
}
- printf("Successfully freed buffer at %#x.\n", (unsigned int) ptr);
+ printf("Successfully freed buffer at %p.\n", ptr);
if (CMEM_exit() < 0) {
fprintf(stderr, "Failed to finalize the CMEM module\n");