From patchwork Fri Dec 12 11:12:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42180 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77C1626C6D for ; Fri, 12 Dec 2014 11:12:51 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf4748968wgh.9 for ; Fri, 12 Dec 2014 03:12:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=XGrdW73tlSMrYfGRuOCWvz47Hmo0RjgZ+eH5rXLVs5o=; b=eOfN4bkaDyPpFY2fafA/r7ms1QEZS3i8mtmik3rJ1LRjf94a0sEma1dVi3yxU2nEwA wSAXNWAzM2p69lZfn9BvafWdXMaLn6YB97Gf7HeNLyxg7zjtHSPLL/+wtjjdt9pBXcV3 5x22w4B9epGcF3L339gcYZkQmsNnH0DjBrDKjX8dcAHf//cFlrFoxr8rmDgIboBayR0r YtWeMx/M5TZxIZ56QyarnidsBiuf8b5WbyRsa+C/b0SGt8ZYb/1+IFbvwOctrAVQBF36 /SiODbyy/mMSS6BWAwzMHuA2xjvnebo3MGalrhwhnnxPXqu9npG6+pvY1S0NuPnhOKBf pyyg== X-Gm-Message-State: ALoCoQmL1mRPdB0LiVsyP5XoBguew9ZlmClN0zMiIKa1L4vI+XMYTtpftFohKXINVdh2Ii+mnk6z X-Received: by 10.152.10.233 with SMTP id l9mr2497758lab.0.1418382770739; Fri, 12 Dec 2014 03:12:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.202 with SMTP id u10ls319227lau.68.gmail; Fri, 12 Dec 2014 03:12:50 -0800 (PST) X-Received: by 10.152.234.169 with SMTP id uf9mr14743147lac.86.1418382770523; Fri, 12 Dec 2014 03:12:50 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id vy6si1024722lbb.88.2014.12.12.03.12.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Dec 2014 03:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so5621837lbi.24 for ; Fri, 12 Dec 2014 03:12:50 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr7536465lbb.2.1418382770381; Fri, 12 Dec 2014 03:12:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp816089lbb; Fri, 12 Dec 2014 03:12:49 -0800 (PST) X-Received: by 10.229.50.135 with SMTP id z7mr29350130qcf.21.1418382769167; Fri, 12 Dec 2014 03:12:49 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 5si1031886qgy.68.2014.12.12.03.12.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 12 Dec 2014 03:12:49 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XzO9M-0003vH-D8; Fri, 12 Dec 2014 11:12:44 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XzO9E-0003ub-R4 for lng-odp@lists.linaro.org; Fri, 12 Dec 2014 11:12:36 +0000 Received: by mail-lb0-f182.google.com with SMTP id f15so6227778lbj.27 for ; Fri, 12 Dec 2014 03:12:30 -0800 (PST) X-Received: by 10.112.136.69 with SMTP id py5mr1483054lbb.56.1418382750855; Fri, 12 Dec 2014 03:12:30 -0800 (PST) Received: from localhost.localdomain (ppp91-76-163-205.pppoe.mtu-net.ru. [91.76.163.205]) by mx.google.com with ESMTPSA id az15sm305842lab.30.2014.12.12.03.12.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Dec 2014 03:12:30 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 12 Dec 2014 14:12:23 +0300 Message-Id: <1418382743-2457-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] example/odp_pktio parse args before odp init X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Reviewed-by: Mike Holmes --- 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;