From patchwork Fri Sep 25 11:58:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Panu Matilainen X-Patchwork-Id: 7187 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 539C38E78; Fri, 25 Sep 2015 13:59:18 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id F1F458D3C for ; Fri, 25 Sep 2015 13:59:13 +0200 (CEST) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 5B947461D8; Fri, 25 Sep 2015 11:59:11 +0000 (UTC) Received: from dhcp195.koti.laiskiainen.org.com (vpn1-4-213.ams2.redhat.com [10.36.4.213]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8PBx87U021625; Fri, 25 Sep 2015 07:59:10 -0400 From: Panu Matilainen To: dev@dpdk.org Date: Fri, 25 Sep 2015 14:58:26 +0300 Message-Id: <4e7a4a9729833c12d51de88b6ecaf6c9ac73267d.1443181743.git.pmatilai@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Subject: [dpdk-dev] [PATCH 1/2] eal: refactor plugin list append from eal_parse_args() to a helper function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Panu Matilainen --- lib/librte_eal/linuxapp/eal/eal.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 33e1067..31f3915 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -530,6 +530,24 @@ eal_log_level_parse(int argc, char **argv) optind = 0; /* reset getopt lib */ } +static int +eal_add_solib(const char *path) +{ + struct shared_driver *solib; + + solib = malloc(sizeof(*solib)); + if (solib == NULL) { + RTE_LOG(ERR, EAL, "malloc(solib) failed\n"); + return -1; + } + memset(solib, 0, sizeof(*solib)); + strncpy(solib->name, path, PATH_MAX-1); + solib->name[PATH_MAX-1] = 0; + TAILQ_INSERT_TAIL(&solib_list, solib, next); + + return 0; +} + /* Parse the argument given in the command line of the application */ static int eal_parse_args(int argc, char **argv) @@ -538,7 +556,6 @@ eal_parse_args(int argc, char **argv) char **argvopt; int option_index; char *prgname = argv[0]; - struct shared_driver *solib; argvopt = argv; @@ -570,15 +587,8 @@ eal_parse_args(int argc, char **argv) /* force loading of external driver */ case 'd': - solib = malloc(sizeof(*solib)); - if (solib == NULL) { - RTE_LOG(ERR, EAL, "malloc(solib) failed\n"); + if (eal_add_solib(optarg) == -1) return -1; - } - memset(solib, 0, sizeof(*solib)); - strncpy(solib->name, optarg, PATH_MAX-1); - solib->name[PATH_MAX-1] = 0; - TAILQ_INSERT_TAIL(&solib_list, solib, next); break; /* long options */