On 16.12.15 16:26, Bill Fischofer wrote:
This patch doesn't appear to apply to the current master. Needs a rebase?
Probably yes, I'll rebase.
bill@Ubuntu15:~/linaro/ivanpatch$ git am --reject ~/Mail/Incoming/Ivan/1 Applying: example: timer: free resources while termination Checking patch example/timer/odp_timer_test.c... Hunk #1 succeeded at 334 (offset 3 lines). Hunk #2 succeeded at 366 (offset 3 lines). error: while searching for: gbls->pool = odp_pool_create("msg_pool", ¶ms); if (gbls->pool == ODP_POOL_INVALID) { EXAMPLE_ERR("Pool create failed.\n"); return -1; } tparams.res_ns = gbls->args.resolution_us*ODP_TIME_USEC; error: patch failed: example/timer/odp_timer_test.c:404 Hunk #4 succeeded at 424 (offset 2 lines). Hunk #5 succeeded at 451 (offset 2 lines). Hunk #6 succeeded at 491 (offset 2 lines). Applying patch example/timer/odp_timer_test.c with 1 reject... Hunk #1 applied cleanly. Hunk #2 applied cleanly. Rejected hunk #3. Hunk #4 applied cleanly. Hunk #5 applied cleanly. Hunk #6 applied cleanly. Patch failed at 0001 example: timer: free resources while termination On Mon, Dec 14, 2015 at 9:29 AM, Ivan Khoronzhuk <ivan.khoronz...@linaro.org <mailto:ivan.khoronz...@linaro.org>> wrote: ping On 19.11.15 12:54, Ivan Khoronzhuk wrote: Example should free resources in right order when terminates. Also it should have correct error path. Signed-off-by: Ivan Khoronzhuk <ivan.khoronz...@linaro.org <mailto:ivan.khoronz...@linaro.org>> --- example/timer/odp_timer_test.c | 46 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 94619e4..2d74e4c 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -331,18 +331,21 @@ int main(int argc, char *argv[]) char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_shm_t shm; test_globals_t *gbls; + int err = 0; printf("\nODP timer example starts\n"); if (odp_init_global(NULL, NULL)) { + err = 1; printf("ODP global init failed.\n"); - return -1; + goto err; } /* Init this thread. */ if (odp_init_local(ODP_THREAD_CONTROL)) { + err = 1; printf("ODP local init failed.\n"); - return -1; + goto err_global; } printf("\n"); @@ -360,14 +363,16 @@ int main(int argc, char *argv[]) shm = odp_shm_reserve("shm_test_globals", sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0); if (ODP_SHM_INVALID == shm) { + err = 1; EXAMPLE_ERR("Error: shared mem reserve failed.\n"); - return -1; + goto err_local; } gbls = odp_shm_addr(shm); if (NULL == gbls) { + err = 1; EXAMPLE_ERR("Error: shared mem alloc failed.\n"); - return -1; + goto err_shm; } memset(gbls, 0, sizeof(test_globals_t)); @@ -404,8 +409,9 @@ int main(int argc, char *argv[]) gbls->pool = odp_pool_create("msg_pool", ¶ms); if (gbls->pool == ODP_POOL_INVALID) { + err = 1; EXAMPLE_ERR("Pool create failed.\n"); - return -1; + goto err_shm; } tparams.res_ns = gbls->args.resolution_us*ODP_TIME_USEC; @@ -416,8 +422,9 @@ int main(int argc, char *argv[]) tparams.clk_src = ODP_CLOCK_CPU; gbls->tp = odp_timer_pool_create("timer_pool", &tparams); if (gbls->tp == ODP_TIMER_POOL_INVALID) { + err = 1; EXAMPLE_ERR("Timer pool create failed.\n"); - return -1; + goto err_msg_pool; } odp_timer_pool_start(); @@ -442,8 +449,9 @@ int main(int argc, char *argv[]) queue = odp_queue_create("timer_queue", ODP_QUEUE_TYPE_SCHED, ¶m); if (queue == ODP_QUEUE_INVALID) { + err = 1; EXAMPLE_ERR("Timer queue create failed.\n"); - return -1; + goto err_timer_pool; } printf("CPU freq %"PRIu64" Hz\n", odp_sys_cpu_hz()); @@ -481,7 +489,29 @@ int main(int argc, char *argv[]) /* Wait for worker threads to exit */ odph_linux_pthread_join(thread_tbl, num_workers); - printf("ODP timer test complete\n\n"); + /* free resources */ + if (odp_queue_destroy(queue)) + err = 1; +err_timer_pool: + odp_timer_pool_destroy(gbls->tp); +err_msg_pool: + if (odp_pool_destroy(gbls->pool)) + err = 1; +err_shm: + if (odp_shm_free(shm)) + err = 1; +err_local: + if (odp_term_local()) + err = 1; +err_global: + if (odp_term_global()) + err = 1; +err: + if (err) { + printf("Err: ODP timer test failed\n\n"); + return -1; + } + printf("ODP timer test complete\n\n"); return 0; } -- Regards, Ivan Khoronzhuk _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> https://lists.linaro.org/mailman/listinfo/lng-odp
-- Regards, Ivan Khoronzhuk _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp