summaryrefslogtreecommitdiff
path: root/tests/pagingtest
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2016-02-02 15:35:33 -0800
committerDan Albert <danalbert@google.com>2016-02-02 16:33:01 -0800
commit879785074ca93e13896ce364a45eb5cc17081c4a (patch)
tree53c9f2456a600403f9cbea126c0c3690b68982c8 /tests/pagingtest
parentdd681db9a7978abeb783af206406cfcae0b8514d (diff)
downloadextras-879785074ca93e13896ce364a45eb5cc17081c4a.tar.gz
Fix warnings in system/extras.
Bug: http://b/26936282 Change-Id: I1b9c6c9bb06944c32abcb871279d056eea0fb11a
Diffstat (limited to 'tests/pagingtest')
-rw-r--r--tests/pagingtest/thrashing_test.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/pagingtest/thrashing_test.c b/tests/pagingtest/thrashing_test.c
index 165cd991..7ecd3ade 100644
--- a/tests/pagingtest/thrashing_test.c
+++ b/tests/pagingtest/thrashing_test.c
@@ -14,7 +14,6 @@ int thrashing_test(int test_runs) {
int fds[4] = {-1, -1, -1, -1};
char tmpnames[4][17] = { "thrashing1XXXXXX", "thrashing2XXXXXX", "thrashing3XXXXXX", "thrashing4XXXXXX" };
volatile char *bufs[4] = {0};
- unsigned i, j;
long long k;
int ret = -1;
struct timeval begin_time, end_time, elapsed_time, total_time;
@@ -33,14 +32,14 @@ int thrashing_test(int test_runs) {
filesize = num_pages * pagesize / (ARRAY_SIZE(fds) - 1);
- for (i = 0; i < ARRAY_SIZE(fds); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
fds[i] = create_tmp_file(tmpnames[i], filesize);
if (fds[i] < 0) {
goto err_fd;
}
}
- for (i = 0; i < ARRAY_SIZE(fds); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(fds); i++) {
bufs[i] = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fds[i], 0);
if (bufs[i] == ((void *)-1)) {
fprintf(stderr, "Failed to mmap file: %s\n", strerror(errno));
@@ -48,8 +47,8 @@ int thrashing_test(int test_runs) {
}
}
- for (i = 0; i < test_runs; i++) {
- for (j = 0; j < ARRAY_SIZE(fds); j++) {
+ for (int i = 0; i < test_runs; i++) {
+ for (size_t j = 0; j < ARRAY_SIZE(fds); j++) {
gettimeofday(&begin_time, NULL);
//Unfortunately when under memory pressure, fadvise and madvise stop working...
//Read backwards to prevent mmap prefetching
@@ -69,11 +68,11 @@ int thrashing_test(int test_runs) {
ret = 0;
err:
- for (i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(bufs) && bufs[i] != NULL; i++) {
munmap((void *)bufs[i], filesize);
}
err_fd:
- for (i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(fds) && fds[i] >= 0; i++) {
close(fds[i]);
}
return ret;