diff options
author | Matias Elo <matias.elo@nokia.com> | 2022-01-03 10:08:30 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2022-01-07 09:52:42 +0200 |
commit | e3c535e3d02b1d38d7a7afc126e49158af13c33d (patch) | |
tree | 57132be128346c952288d48b2767c941b8ab321b /example | |
parent | 0d37ee839401e36add1b2e054ae1fca0518e9a1c (diff) |
example: timer_accuracy: close output file on failure
Previously, the output file was not closed if odp_init_global() or
odp_init_local() call failed.
Fixes: https://github.com/OpenDataPlane/odp/issues/1457
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'example')
-rw-r--r-- | example/timer/odp_timer_accuracy.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/example/timer/odp_timer_accuracy.c b/example/timer/odp_timer_accuracy.c index 9318e1090..b7fc55701 100644 --- a/example/timer/odp_timer_accuracy.c +++ b/example/timer/odp_timer_accuracy.c @@ -1,10 +1,11 @@ /* Copyright (c) 2018, Linaro Limited - * Copyright (c) 2019-2021, Nokia + * Copyright (c) 2019-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ +#include <errno.h> #include <stdio.h> #include <string.h> #include <inttypes.h> @@ -717,15 +718,6 @@ int main(int argc, char *argv[]) if (parse_options(argc, argv, &test_global)) return -1; - if (test_global.opt.output) { - test_global.file = fopen(test_global.filename, "w"); - if (test_global.file == NULL) { - printf("Failed to open file: %s\n", - test_global.filename); - return -1; - } - } - /* List features not to be used (may optimize performance) */ odp_init_param_init(&init); init.not_used.feat.cls = 1; @@ -767,6 +759,14 @@ int main(int argc, char *argv[]) void *addr; uint64_t size = test_global.tot_timers * sizeof(test_log_t); + test_global.file = fopen(test_global.filename, "w"); + if (test_global.file == NULL) { + printf("Failed to open output file %s: %s\n", + test_global.filename, strerror(errno)); + ret = -1; + goto quit; + } + shm = odp_shm_reserve("timer_accuracy_log", size, sizeof(test_log_t), 0); |