diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2018-07-13 18:30:52 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2018-07-13 18:30:52 +0200 |
| commit | 4c77b526f007adcea373f9589cac3a35ffc77edc (patch) | |
| tree | 35f2adce2ea701b4edaa148e29dccf37fdfc32f2 /bench_loop.c | |
| parent | bff09822125125d6eaf6d555ea7a6a8908bda79c (diff) | |
| download | allocbench-4c77b526f007adcea373f9589cac3a35ffc77edc.tar.gz allocbench-4c77b526f007adcea373f9589cac3a35ffc77edc.zip | |
fix compiler warnings and add error reporting
Diffstat (limited to 'bench_loop.c')
| -rw-r--r-- | bench_loop.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/bench_loop.c b/bench_loop.c index 03eac25..b1c8d13 100644 --- a/bench_loop.c +++ b/bench_loop.c @@ -38,7 +38,7 @@ static void* malloc_then_write(size_t size) { static void read_then_free(void* ptr) { // Read before free - char s = *((char*)ptr); + char s __attribute__((unused)) = *((char*)ptr); free(ptr); } static void* test_thread_func(void* arg) { @@ -56,7 +56,7 @@ static void* test_thread_func(void* arg) { if (args->benchmark == 1.2) { if (pos == 0 && ptrs[pos] != NULL) { - for (size_t y = 0; y < args->num_kept_allocations; y++) { + for (int y = 0; y < args->num_kept_allocations; y++) { read_then_free(ptrs[y]); } } @@ -91,19 +91,24 @@ int main(int argc, char* argv[]) { for (int i = 0; i < num_threads; i++) { if (0 != pthread_create(&threads[i], NULL, test_thread_func, &thread_args)) { + perror("pthread_create"); return 1; } } for(int i = 0; i < num_threads; i++) { if (0 != pthread_join(threads[i], NULL)) { + perror("pthread_join"); return 1; } } -#ifndef NSTATS - FILE* f = fopen("stats", "w"); + FILE* f = stdout; + if (argc == 7) + f = fopen(argv[6], "w"); malloc_info(0, f); - fclose(f); -#endif + if (argc == 7) + fclose(f); + + return 0; } |
