diff options
author | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-12-12 14:12:23 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-12-15 15:13:08 +0300 |
commit | 7e924cfb0b230795e4f372cdb0d57fb2e1141732 (patch) | |
tree | 9f678b5aaaef66feded2050cf5dac7bc8ca5a51d /example/packet/odp_pktio.c | |
parent | c7a72ff2c539a0315eed1a6e0de04a1d277c2a69 (diff) |
example/odp_pktio parse args before odp init
No need to init odp if example args are not valid.
https://bugs.linaro.org/show_bug.cgi?id=856
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Reviewed-by: Mike Holmes <mike.holmes@linaro.org>
Diffstat (limited to 'example/packet/odp_pktio.c')
-rw-r--r-- | example/packet/odp_pktio.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index eceee15..607ecbf 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -337,6 +337,15 @@ int main(int argc, char *argv[]) int core_count; odp_shm_t shm; + args = calloc(1, sizeof(args_t)); + if (args == NULL) { + EXAMPLE_ERR("Error: args mem alloc failed.\n"); + exit(EXIT_FAILURE); + } + + /* Parse and store the application arguments */ + parse_args(argc, argv, &args->appl); + /* Init ODP before calling anything else */ if (odp_init_global(NULL, NULL)) { EXAMPLE_ERR("Error: ODP global init failed.\n"); @@ -349,20 +358,6 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - /* Reserve memory for args from shared mem */ - shm = odp_shm_reserve("shm_args", sizeof(args_t), - ODP_CACHE_LINE_SIZE, 0); - args = odp_shm_addr(shm); - - if (args == NULL) { - EXAMPLE_ERR("Error: shared mem alloc failed.\n"); - exit(EXIT_FAILURE); - } - memset(args, 0, sizeof(*args)); - - /* Parse and store the application arguments */ - parse_args(argc, argv, &args->appl); - /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); @@ -441,6 +436,7 @@ int main(int argc, char *argv[]) /* Master thread waits for other threads to exit */ odph_linux_pthread_join(thread_tbl, num_workers); + free(args); printf("Exit\n\n"); return 0; |