From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 4A30C1BDB1 for ; Thu, 20 Dec 2018 18:07:25 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id t6so2525655wrr.12 for ; Thu, 20 Dec 2018 09:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fq/+lKpw0k3c0gxNQ7oXHZFU55uXKlpp/hK4aJLsNsw=; b=1kXIxjcvcMAsPhCBZLWmbH1V1bVPxbg1Y5Nef9CmN4udx7Xyf9tFGPV7bxlBapjJDb ntBWubuoe6RL2q7/n4vaThU0FaObUxMnythBPXsmF6EBxFaLX6RQw/cOU0Fsg+bD+zNP Xsj0o5XBuRyUeWGlybysQi8l2YjrDjcL3VJtlRKfgUFlG0as67PfAK/hImw9rm9pzT3L ZWYkW3oFnUXm20J4+MznvzegykUxsgDbonW4D2UQdJAHns0KGlQF3mZMYvFRBNhaAGzP n6Slqzb3Au1BLM9wsQwYwB3nVKB9pmuVMYTSRCvdn8nPnV650ccF8AU3vV9kdzPlgIyM ihKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fq/+lKpw0k3c0gxNQ7oXHZFU55uXKlpp/hK4aJLsNsw=; b=Y6APPaxeSk5NtzxHRJixzCxvM//VFtB92Gs4GlZFe3VotzE5SqNABUn4eZ4a0z/aSV Mwv3mw50seFlknZieNMTbU3F7sHEg+AXxWZnfin4G8l6KdaRSm4a4YThbP1fYxCj3pB4 k2OPaTwH63FqoezkWjuEwlVB9/Kcl92RNl2nybGr8sGzYx02z5R8NIeQ1YVXr1cweUvh ETbQjyj3Nmyu0zBnXK0I+InS35oQ+WiOx1Dg+RrdJoqc4VpehygFvyttqpsmH0spFfqq PTx6SAOomNARx1GE9/xg3DavJZLCwGb9kJp6NexiHrYD17ns60N3pDfgCO06ZBDi4laL PoZQ== X-Gm-Message-State: AA+aEWYxEL0dOkviLTijwL3QZ10FYid2nccfAZpumGerxDuhK7CFZAzw SJYW95LI/pFPEiW5Ezc8ngfwlDXO33Q= X-Google-Smtp-Source: AFSGD/VRNzjMAiPxK4zJcQwAJfooWif4j8Z+VhmABJsvcBtgJs1weuG1aqlXnWqSnjX2MRDhiXwqBw== X-Received: by 2002:adf:fd03:: with SMTP id e3mr22489130wrr.280.1545325644620; Thu, 20 Dec 2018 09:07:24 -0800 (PST) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id n5sm11951688wrr.94.2018.12.20.09.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:23 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:47 +0100 Message-Id: <4a38da694ec265a04da45810aa1ea64ae9fa4e8a.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 8/8] option: return an error when register fail X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 17:07:25 -0000 Make rte_option_register return a negative value when an error occur. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_option.h | 6 +++++- lib/librte_eal/common/rte_option.c | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h index 20be47d91..7ad65a4eb 100644 --- a/lib/librte_eal/common/include/rte_option.h +++ b/lib/librte_eal/common/include/rte_option.h @@ -57,8 +57,12 @@ struct rte_option { * * @param opt * Structure describing the option to parse. + * + * @return + * 0 on success, <0 otherwise. */ -void __rte_experimental +__rte_experimental +int rte_option_register(struct rte_option *opt); #ifdef __cplusplus diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index b2c93b220..fe7f2ab4e 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -38,7 +38,8 @@ rte_option_parse(const char *opt) return -1; } -void __rte_experimental +__rte_experimental +int rte_option_register(struct rte_option *opt) { struct rte_option *option; @@ -49,7 +50,7 @@ rte_option_register(struct rte_option *opt) if (strcmp(gopt->name, opt->name) == 0) { RTE_LOG(ERR, EAL, "Option %s is already a common EAL option.\n", opt->name); - return; + return -1; } gopt++; } @@ -58,11 +59,12 @@ rte_option_register(struct rte_option *opt) if (strcmp(opt->name, option->name) == 0) { RTE_LOG(ERR, EAL, "Option %s has already been registered.\n", opt->name); - return; + return -1; } } TAILQ_INSERT_HEAD(&rte_option_list, opt, next); + return 0; } void -- 2.19.1