Message ID | 1418382743-2457-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | Accepted |
Commit | 7e924cfb0b230795e4f372cdb0d57fb2e1141732 |
Headers | show |
On 12 December 2014 at 06:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > > 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> > --- > example/packet/odp_pktio.c | 24 ++++++++++-------------- > 1 file 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; > -- > 1.8.5.1.163.gd7aced9 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
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;
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> --- example/packet/odp_pktio.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)