From patchwork Fri Oct 16 11:58:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Panu Matilainen X-Patchwork-Id: 7703 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 CDAB78DA9; Fri, 16 Oct 2015 13:58:29 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id DB67A592B for ; Fri, 16 Oct 2015 13:58:26 +0200 (CEST) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 21D0BC1C9107; Fri, 16 Oct 2015 11:58:25 +0000 (UTC) Received: from dhcp195.koti.laiskiainen.org.com (vpn1-6-41.ams2.redhat.com [10.36.6.41]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9GBwMXL015206; Fri, 16 Oct 2015 07:58:24 -0400 From: Panu Matilainen To: dev@dpdk.org Date: Fri, 16 Oct 2015 14:58:13 +0300 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Subject: [dpdk-dev] [PATCH 1/5] 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..cc66d9f 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_plugin_add(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_plugin_add(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 */