From patchwork Thu Dec 20 17:06:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49201 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D8A221BD28; Thu, 20 Dec 2018 18:07:18 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id D337A1BBD6 for ; Thu, 20 Dec 2018 18:07:15 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id g67so3022870wmd.2 for ; Thu, 20 Dec 2018 09:07:15 -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=WmIS9ZkPNRB9weAc5xdzDHhrqdkitG4bISd9+SLc1rA=; b=KeDconFEkz8Fk9Oo6de9lUGOHYaYL9LZMcaMYEnAPQ9s9hgDEbFjkTOpQ1OD7lQh4O 1J12sxBv0LAjM5VJs45fpXD93AYHaA1vkv70pTKBPMcPjjPKJxgrJcUxwpIeIxWxv09c mZddYgY96Cb4VOpdVWyPU5SZb6CddtudiernbTc5SMKAHrffrbzgAl28MLQlQZwC/MZg RiDIVrb5mdFROK0ahTvAP4P9OU76hT3rstL5XQayfUqWfmfQgI/zMZfFyWfpew39Lzaz eP8yDld7p5PvVy71qb6KistoJsHopULDpoPVuPEqmDLRCUONpk8fVNld71S6qj0pAM4J 4l+A== 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=WmIS9ZkPNRB9weAc5xdzDHhrqdkitG4bISd9+SLc1rA=; b=jmeYqeodLn2M1lMx7+rqs6DwvQqnFdQrCItgpgFaE4JLhqKYMSroc5aGsJICMFBVxG n5d6fLU+vTlD+8z1YOZ2qHV83k/IeK3IJ+XuV6cQdkeY+kO3h/hcYwEx9jUsIb16RrTb ujrsTRvgPQTuLSW9i//o3NYplXWXj/Yk8YDaCyeSwBimtNWAINKIaf9Q7FWeKHJcbryg nmVS915QEY9UA16vCgP0oyY26F6UFCftKBGarX1PK3PA7+aeQN8MWtuqt9RQmgrsjD+x oSa5duvAJmPenUoAvaCXZ0vI6dcgNkLG461ep+VhPg9y3rv2s7CbSADpjI4UbuScPzDT bykw== X-Gm-Message-State: AA+aEWYDrjdsIFxE2VKDzEdCTeiXj2+dwD6acDI8EBrnCv6LZ7Z7xGlu jxc15n0gqooCxD5EIpuqTqEVGOKFu9c= X-Google-Smtp-Source: AFSGD/VvWhacYMkOOtyT8EITeqofURETrjR5Xg017tmCYln+2Yr/GM0c7HaZyVcg9QsG7rrjap8uRA== X-Received: by 2002:a1c:b687:: with SMTP id g129mr12097342wmf.59.1545325635081; Thu, 20 Dec 2018 09:07:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:14 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:40 +0100 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 1/8] option: use bare option string as name 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Current options name can be passed with arbitrary format. Force the use of "--" prefix and thus POSIX long options format. This restricts the ability to introduce surprising options and will help future additional checks. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/rte_option.c | 6 +++++- lib/librte_telemetry/rte_telemetry.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index 088e0fd23..3fbc13a6a 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -20,9 +20,13 @@ static struct rte_option *option; int rte_option_parse(const char *opt) { + if (strlen(opt) <= 2 || + strncmp(opt, "--", 2)) + return -1; + /* Check if the option is registered */ TAILQ_FOREACH(option, &rte_option_list, next) { - if (strcmp(opt, option->opt_str) == 0) { + if (strcmp(&opt[2], option->opt_str) == 0) { option->enabled = 1; return 0; } diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index 016431f12..3080bb715 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -1798,7 +1798,7 @@ rte_telemetry_json_socket_message_test(struct telemetry_impl *telemetry, int fd) int telemetry_log_level; static struct rte_option option = { - .opt_str = "--telemetry", + .opt_str = "telemetry", .cb = &rte_telemetry_init, .enabled = 0 }; From patchwork Thu Dec 20 17:06:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49202 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6E93D1BD78; Thu, 20 Dec 2018 18:07:20 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 3DA001BCCF for ; Thu, 20 Dec 2018 18:07:17 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id r24so12397402wmh.0 for ; Thu, 20 Dec 2018 09:07:17 -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=QyflGv3uVWe6WdAjb03D3aYliOhakZZdmEIM7SCbjak=; b=0GhS/pEO28cQKsicmUosrSECq1vm7UizMOcjioE635QR9cIPVfMaj6uOT6/zXGLYFw GJASRTAca8NKb6SfL2RW5mvVJ4toGBPo3rg+USt65gJypjQ7Z1n7DBSgFOSTkqJicDK+ +OsSNjJuLyOEXXnOrpHwkmEBIXKYi9XrihHIPkgRmAXFuDSwRJ9IEciYjUrOldgbf1NN nhdtb/tQvivRcFAIBPEfgn+9D4uYzZtqBz2uMwHScsVQuO5lUrRiJ3yT/bRVgMgxudPx O/EiuKzavT5iWWIOUhzJc7SlorV7YEULsccErHQaJI9W6zGUw5o+QU1Xnf2M993mkj2p 2kIw== 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=QyflGv3uVWe6WdAjb03D3aYliOhakZZdmEIM7SCbjak=; b=M8KSTsEO0dadsHh7EiSUhYsv1wrWn6PPzL4o8VTHlkfYmzJyWYJJD+I9ymT4WhpVTs Rcjrp78DLRRrF/J1WNmjhDVB3eqz54hkngJKNJSFuO+EqvINI2Afls0/glmh+p9JvNm6 hTm/t2RhhJDanDmoOcwzGE+kWT6PR3VoU8w2FhO6UueTAJSuH6wXVPy1CsPuP7d8Cy6n d2ovWrt5wauXq020Bq/skyMYNjyOVBX50pHRKBWgX9KtU09DtUL/zU86LTSSpEz0h87A YyhnNG/g7gulPZtUc1SdW3fmlT3wbAlhynRceKvtUt6sfTyxYkntP5s7ZeEEgdKXWuly WhMA== X-Gm-Message-State: AA+aEWa8fdXTcjugwGh9PQyaSWgYn1/aL6P1L6hKTZzLWTJXpjhlfvPo rQUEJuvES8SNSwtWjvIG7e0Glr9i8Cs= X-Google-Smtp-Source: AFSGD/XsIwy3vys3OLxj1hr4b/y0JyUu7IHwgVTwXcz5SyJjTz6x5ErizkboDrh8vX8Fjd8DMmRIEQ== X-Received: by 2002:a1c:b70b:: with SMTP id h11mr12669913wmf.72.1545325636248; Thu, 20 Dec 2018 09:07:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:15 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:41 +0100 Message-Id: <1a4e58797e63142a15039bd288e746bb1c6684ce.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 2/8] option: do not use static iterator 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is rather weird. Someone should have caught that during review. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/rte_option.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index 3fbc13a6a..9e233f7d2 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -15,11 +15,11 @@ TAILQ_HEAD(rte_option_list, rte_option); struct rte_option_list rte_option_list = TAILQ_HEAD_INITIALIZER(rte_option_list); -static struct rte_option *option; - int rte_option_parse(const char *opt) { + struct rte_option *option; + if (strlen(opt) <= 2 || strncmp(opt, "--", 2)) return -1; @@ -38,6 +38,8 @@ rte_option_parse(const char *opt) void __rte_experimental rte_option_register(struct rte_option *opt) { + struct rte_option *option; + TAILQ_FOREACH(option, &rte_option_list, next) { if (strcmp(opt->opt_str, option->opt_str) == 0) { RTE_LOG(INFO, EAL, "Option %s has already been registered.\n", @@ -52,6 +54,8 @@ rte_option_register(struct rte_option *opt) void rte_option_init(void) { + struct rte_option *option; + TAILQ_FOREACH(option, &rte_option_list, next) { if (option->enabled) option->cb(); From patchwork Thu Dec 20 17:06:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49203 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35D3A1BDAC; Thu, 20 Dec 2018 18:07:22 +0100 (CET) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 8F63C1BD0F for ; Thu, 20 Dec 2018 18:07:18 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id q18so2524437wrx.9 for ; Thu, 20 Dec 2018 09:07:18 -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=TGnxPXPdq0yaEqE6pmJxxStUY2QI/1SenqJI0IH2H3c=; b=HK71wVZdaQ3ZjC/EWq0X2W+XHxTc3C70JEQCm67Xf5f9z0Zm9HnIIk8DXmP0et9OFn IzNCBjELveEcqAwuyMiQKYEmE0jY2/uBMhASgiQacZ9mFTANkmARF6GWGaIOaKz6SOfI nGaA61AEk3WViVhO9b8HrxzOctTS4uca9ett72qslctYR2GKM4UMsj//+0qy/io/eIW2 F2wM4oeSi7rofmSXuXXUFfu3nWFTt0OxdYRUIt4zbC9odJJtWCgsHphQcThXKvqcykdQ tXEuZDgaL0RnlXF/c2vymsyxOLAMY/R/zJLr/BtbLMW0XEjpkn26Qy14SynbHvS54UrW rD2Q== 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=TGnxPXPdq0yaEqE6pmJxxStUY2QI/1SenqJI0IH2H3c=; b=Ral5pr//cTY6Hy6KqdoP2Y0byY6San83hleGf9L41nge0EoH+JNI7yftBHkg+3fdVB UK4jY86XoAkYP7kUMtzkxSdxAvOjlMhpgdte710MdagInJdPrvsLLQY5nQwQYa9beuty RBxjIdOI+WrkjFr3OGjjQh7URDutlvo8rjlLG5xHWAOfZ3n1/rboP6+FWNP86FEE/zV6 0ytXDK0WUFYPYAHbwudae+4xhUw24FJLUGH72TqMTrFJvDN4hNCjYUKVSN6tFDMQt6cR nMO1JuGuu9ml1rtajtyKrYmRrKfQAbB2moYMhrNSNyEoaMw6il7QjB9voGMHPe52paHK Q7Gg== X-Gm-Message-State: AA+aEWbEh0HdPR9VcNcgkLsYbarIxppG0TqjoBztlS0mZY9i5shhmjrU IBFSChTFigCtJDyGFJTcR8A2djarcOQ= X-Google-Smtp-Source: AFSGD/XIFSyjfae1DjEpn1nHyWfThMei2aEEIcVoU7bih2Q0pebDv8Hg59d12mHzdvnt5R28b3um+w== X-Received: by 2002:adf:c7cc:: with SMTP id y12mr24290538wrg.52.1545325637739; Thu, 20 Dec 2018 09:07:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:16 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:42 +0100 Message-Id: <1f284decd3c8d5398d6d0fb5ef7cc024562dc219.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 3/8] option: add usage string 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add a usage string field in rte_option, allowing to display help to the user and describe which options are currently available. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_options.c | 1 + lib/librte_eal/common/eal_private.h | 7 +++++++ lib/librte_eal/common/include/rte_option.h | 1 + lib/librte_eal/common/rte_option.c | 17 +++++++++++++++++ lib/librte_telemetry/rte_telemetry.c | 1 + 5 files changed, 27 insertions(+) diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 6e3a83b98..e096ac896 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1494,4 +1494,5 @@ eal_common_usage(void) " --"OPT_NO_HPET" Disable HPET\n" " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n" "\n", RTE_MAX_LCORE); + rte_option_usage(); } diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 442c6dc48..50ab58385 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -370,4 +370,11 @@ rte_option_parse(const char *opt); void rte_option_init(void); +/** + * Iterate through the registered options and show the associated + * usage string. + */ +void +rte_option_usage(void); + #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h index 8957b970c..bbcc6cec9 100644 --- a/lib/librte_eal/common/include/rte_option.h +++ b/lib/librte_eal/common/include/rte_option.h @@ -35,6 +35,7 @@ typedef int (*rte_option_cb)(void); struct rte_option { TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */ char *opt_str; /**< The option name. */ + const char *usage; /**< Option summary string. */ rte_option_cb cb; /**< Function called when option is used. */ int enabled; /**< Set when the option is used. */ }; diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index 9e233f7d2..2ed74873b 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -61,3 +61,20 @@ rte_option_init(void) option->cb(); } } + +void +rte_option_usage(void) +{ + struct rte_option *option; + int opt_count = 0; + + TAILQ_FOREACH(option, &rte_option_list, next) + opt_count += 1; + if (opt_count == 0) + return; + + printf("EAL dynamic options:\n"); + TAILQ_FOREACH(option, &rte_option_list, next) + printf(" --%-*s %s\n", 17, option->opt_str, option->usage); + printf("\n"); +} diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index 3080bb715..0ba6626c1 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -1799,6 +1799,7 @@ int telemetry_log_level; static struct rte_option option = { .opt_str = "telemetry", + .usage = "Enable telemetry backend", .cb = &rte_telemetry_init, .enabled = 0 }; From patchwork Thu Dec 20 17:06:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49204 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 124901BDB3; Thu, 20 Dec 2018 18:07:24 +0100 (CET) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 175F21BD78 for ; Thu, 20 Dec 2018 18:07:20 +0100 (CET) Received: by mail-wr1-f65.google.com with SMTP id u4so2537128wrp.3 for ; Thu, 20 Dec 2018 09:07:20 -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=P2npiJFGxtEAvJUY0SsDOH23cB3yWfyPopJj5zBAsw0=; b=Txz//tAdze7tb2U6wLCP9bjB90cmJcrUDyK5O+Gg5DtYEHzUWgb3d9dvR2nGlkP9D8 wW2a7qJsbXJhmbMW/cuHNH9gD+yv3MsDerbS3+rxT9meyISMVo5V6Gt/fjI6Z0p9uB01 Z/VN1enJV4xO/8ym2rY8O2T8aE9HPSXaAZmXkQFbEMG1RN82SObky6EMZW4okpWgEq+U MmuSnMVe/LIUDQkuibRPiobWOCs0+1jBznPCKM8ewC+5Abr05EDl3f3O/jpQy2ZI3lRU 5C6ZG/c91/vm8nGS0poDwrUpAepGdtAEJYzZun2x4UmQNmKB92QYyBrQFOIdbeyZVDk7 oiBQ== 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=P2npiJFGxtEAvJUY0SsDOH23cB3yWfyPopJj5zBAsw0=; b=kehAQgVObcHcUBHnkSMoLS/vs6TBAl1RnvNW0BmquowDbbQzxKXYkiAKRmQK+88dBm Etvv+iWLvXsTGuX3RF+1LM53y1EjjmxA0NEsVDkip6UkApyEJmpD49WFyJX6XZOEpHj0 myBr+Lwm97raR5XMSgVOAbO26QFiyZKzR8SJ9sFGlIooGdvWNQHh8V+3/Mmg+D5VjO9V VsgH6RuQE1rNA2Df9WsXbHBNnIZsYa9iOoaY5qy2gPhe9jx0aWNLFfUs6lcfF7XbaOXQ m0HFoQiBjYPtTGREPjX67SUZ13aEul8SENZbETS+bs/B/3x2fOmDNd+SmcxJQHtOLKwb 19qQ== X-Gm-Message-State: AA+aEWaUBtp1e03KDThnuwf7yYfzgQNco6mCNy5ZTqki02dyVCOuDa+l D4/LvELHKAIiCz6ugPGZYV9N3HKfFFQ= X-Google-Smtp-Source: AFSGD/W+GMaKPcTRPbO9VdG83E67IVAJBevvOToRez6BMb8uWXNZHYQn/1+OfVtABpVhKkunOC+e8Q== X-Received: by 2002:adf:f703:: with SMTP id r3mr22919878wrp.93.1545325639234; Thu, 20 Dec 2018 09:07:19 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:18 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:43 +0100 Message-Id: <5ed62946ea2ffd627c5422bb5569cb0841f88a69.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 4/8] option: rename name field 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" option->opt_* is redundant. The field should also be constant. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_option.h | 2 +- lib/librte_eal/common/rte_option.c | 8 ++++---- lib/librte_telemetry/rte_telemetry.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h index bbcc6cec9..eea95e477 100644 --- a/lib/librte_eal/common/include/rte_option.h +++ b/lib/librte_eal/common/include/rte_option.h @@ -34,7 +34,7 @@ typedef int (*rte_option_cb)(void); */ struct rte_option { TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */ - char *opt_str; /**< The option name. */ + const char *name; /**< The option name. */ const char *usage; /**< Option summary string. */ rte_option_cb cb; /**< Function called when option is used. */ int enabled; /**< Set when the option is used. */ diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index 2ed74873b..d94363872 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -26,7 +26,7 @@ rte_option_parse(const char *opt) /* Check if the option is registered */ TAILQ_FOREACH(option, &rte_option_list, next) { - if (strcmp(&opt[2], option->opt_str) == 0) { + if (strcmp(&opt[2], option->name) == 0) { option->enabled = 1; return 0; } @@ -41,9 +41,9 @@ rte_option_register(struct rte_option *opt) struct rte_option *option; TAILQ_FOREACH(option, &rte_option_list, next) { - if (strcmp(opt->opt_str, option->opt_str) == 0) { + if (strcmp(opt->name, option->name) == 0) { RTE_LOG(INFO, EAL, "Option %s has already been registered.\n", - opt->opt_str); + opt->name); return; } } @@ -75,6 +75,6 @@ rte_option_usage(void) printf("EAL dynamic options:\n"); TAILQ_FOREACH(option, &rte_option_list, next) - printf(" --%-*s %s\n", 17, option->opt_str, option->usage); + printf(" --%-*s %s\n", 17, option->name, option->usage); printf("\n"); } diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index 0ba6626c1..3ba7ae8de 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -1798,7 +1798,7 @@ rte_telemetry_json_socket_message_test(struct telemetry_impl *telemetry, int fd) int telemetry_log_level; static struct rte_option option = { - .opt_str = "telemetry", + .name = "telemetry", .usage = "Enable telemetry backend", .cb = &rte_telemetry_init, .enabled = 0 From patchwork Thu Dec 20 17:06:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49205 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7AC371BDB8; Thu, 20 Dec 2018 18:07:25 +0100 (CET) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 7984C1BD7E for ; Thu, 20 Dec 2018 18:07:21 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id v13so2531754wrw.5 for ; Thu, 20 Dec 2018 09:07:21 -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=uie/3rwQ24KmeEpvlOrXaqi5jI/o7o1nZhLCcUAXDZQ=; b=khEzqVlpZx98cx+QcJ/YCq6syTf4WYUhCc9sJfBZAAQuPtqS2zFZeXtVirwsdwzKXP 5GeAHiw952mlFqNDCBVQGeH5Wily6Nxo2VD2d+IDc44LvcWk55BgPo5MSdZtq+NccTsK 5oLFYbCX4RAZ/xphw7f4sRt1bUpYyM12rVZC4WSOggmRadvJjwlc560KaIhMflWu44Gx muIHb9jerGwiJIaOJd+e12AeyrYZOHjDr1a5a+vD98J7E7Fd8Vatv/YTSch6z+EU8WED skbUdkuaCVQSNHflDPmXizwiYnN+9cHb5Nq6FCzP0FVd0r99vZsY3V/jvTdW8ttZyrqn WmiQ== 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=uie/3rwQ24KmeEpvlOrXaqi5jI/o7o1nZhLCcUAXDZQ=; b=T1lqMYiJd00NPUPRqO/p0rhlIP+RX4oM7nPtS7G4ZQdfQOESvjv3PUM01/dP3CBdW8 zugUFcpHat43FhAm7gwkvtL/Ln9/kzUOZ7rJ3CGcn8kovp7NLFhHDSXu9hSEKKl1r/m8 s2pJgnZVc6FMcLyRKD73EWdo8mcGUPhubqzCIHQVNLdOxTYccMYECt9h31FzaInx+FRn Dk0St7LriCGgLNBmhIGUtpaGvfHc0Ohdih1nrDIgb68o/dnXSHVHW6OkH3EFys00XNEX PNbOt8m7gTVac3DjH0EO8TmMJd2FxU17FZ6y/zYPOB08w/HJeDsgEY9oktsJ63q24GlF WV4A== X-Gm-Message-State: AA+aEWbqVjnlW3JiilvjadmT7E/Hh4OMuHc0/t+DXc3bPXlTq3w8eUKI vcRL2zCz+Vy4b+gsO7hFKYBcpiIbVgQ= X-Google-Smtp-Source: AFSGD/UHBu2BQsdI/8FP7ejNIzu3bWoGl2dxo6jeiWa7gwRqxYfg6Xysdrtduwge4lBcM2bjEIo47A== X-Received: by 2002:adf:a357:: with SMTP id d23mr24294425wrb.195.1545325640702; Thu, 20 Dec 2018 09:07:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:19 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:44 +0100 Message-Id: <64e6b0b1b696b3e99e28ab35f42b1e94e8e42582.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 5/8] option: check against common option on register 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Not only check against other registered options, but also common EAL options. This will mitigate user confusion. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/rte_option.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index d94363872..ae8a0e2ca 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -2,6 +2,7 @@ * Copyright(c) 2018 Intel Corporation. */ +#include #include #include @@ -9,6 +10,8 @@ #include #include "eal_private.h" +#include "eal_internal_cfg.h" /* Necessary for eal_options.h */ +#include "eal_options.h" TAILQ_HEAD(rte_option_list, rte_option); @@ -39,6 +42,17 @@ void __rte_experimental rte_option_register(struct rte_option *opt) { struct rte_option *option; + const struct option *gopt; + + gopt = &eal_long_options[0]; + while (gopt->name != NULL) { + if (strcmp(gopt->name, opt->name) == 0) { + RTE_LOG(ERR, EAL, "Option %s is already a common EAL option.\n", + opt->name); + return; + } + gopt++; + } TAILQ_FOREACH(option, &rte_option_list, next) { if (strcmp(opt->name, option->name) == 0) { From patchwork Thu Dec 20 17:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49206 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 399401BDBD; Thu, 20 Dec 2018 18:07:27 +0100 (CET) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id CFE591BC73 for ; Thu, 20 Dec 2018 18:07:22 +0100 (CET) Received: by mail-wr1-f68.google.com with SMTP id x10so2520436wrs.8 for ; Thu, 20 Dec 2018 09:07:22 -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=f1r0ohynzPVrWW+cR+Zsc/pmk7Xt1biUdlspZf8ZVa8=; b=P315Sk62NhNSN9u0AxOP7J6adcq/ka5OClbIfgjpg7ffDlLDoUYYwWEFUVI4il9X20 NuxTXfTFXpHpW+PMW/OABpQQbDLA5fSjfSBrorOaH1oQjyp/Zca9RfMxCeKspf5YsQbM RX1NDDkbyY9SitfzcaN4s3LkhfWwgJi+D8KFLyLbUfIvniweSIQIaOSwu2yYYuCvXeHq 6arWr5wVy22UprX99jkuTtJb8HKJw5XQ6hSBhAkzGe9g4GjRe1U4ZJk+i2f7CR3tnSrr XfliKIAJ1f1ZPjtEhkV/B0dNoy/QkTsTIG6+nz4kT8JpePqApsYVK3oaYaAG5X2+uJQJ pWzQ== 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=f1r0ohynzPVrWW+cR+Zsc/pmk7Xt1biUdlspZf8ZVa8=; b=HdB4K6tPvsuvOqCvs4FqBzHEtcPna8atnx/EgE1j2yg9fBqccNm5u619O+th1Rmq+8 OojoHHPNYSilnBQhAe6zkFJ5l3+Xa+W0+zbil8veQRrw4fZ4BstHxhd89XMemzHZjGHy rfSqB3GSHDDMjcdSaiNoI5SgqtJRRDZQQJILrDehenKae9TQ1EusCH//8d9Qj66VdJOf KWFOyvTOrmKWsZvcmskj/CRXLFbvQRR43ZWM/06LqQu1UcqtCVlRPX8t4KlfVc3mh1lj Ywm3QTVqpvCR53Z9ysANvKJ8f2N13+emwzBufg6L4tK7fFoZ0KDeFJ96gp8t/zcXuLvu BJNQ== X-Gm-Message-State: AA+aEWayVCvNbY+sBrjSEWgULZEHdRuTHQRCJBEXsJM3+zaog/XX7W11 IZ4JM09pe1eCF+Zeiwgm+x8+aj59tw4= X-Google-Smtp-Source: AFSGD/VQh/+EWJFF1DSKsSmiuCq/E4ohoqgBbH5EVf54zIDCu92yOZgC/FvfgYb5dIz5DtNFQYO4MA== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr23088136wrq.38.1545325642063; Thu, 20 Dec 2018 09:07:22 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:21 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:45 +0100 Message-Id: <64f85562258c23baf01c97a3904be7d85cace95f.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 6/8] option: fix log level of error in register 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" INFO is not correct when logging an error. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/rte_option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index ae8a0e2ca..b2c93b220 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -56,7 +56,7 @@ rte_option_register(struct rte_option *opt) TAILQ_FOREACH(option, &rte_option_list, next) { if (strcmp(opt->name, option->name) == 0) { - RTE_LOG(INFO, EAL, "Option %s has already been registered.\n", + RTE_LOG(ERR, EAL, "Option %s has already been registered.\n", opt->name); return; } From patchwork Thu Dec 20 17:06:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49207 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F10401BDC5; Thu, 20 Dec 2018 18:07:28 +0100 (CET) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id EF4131BDB1 for ; Thu, 20 Dec 2018 18:07:23 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id f81so3004218wmd.4 for ; Thu, 20 Dec 2018 09:07:23 -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=PdVUbYdVmLlIKxvlsWpjolkRTGhn88OQckZovHVie98=; b=1MKNg0Qf8Adbq0OMJffc3GVGLzvpgEEXuQq6v25CnRMRzpqFDcxglCoqw/S2GvbwfT rDp54e9mPpG2tMlDBvuIRN5MYxJx0hRhtODH0tiKTd+NCr4nVvSknCe0vB6EIBKBRD1i GOmo2CR/kSEPNfW0V6E5Yu3LOEFhUkPTirVQLFxrt0+knEoEJZTStpCyDCnu0Kyr0XuK bMllB7K1nJemLzMp15BhQevjHCylkd1A7B76ETc9T3akf1MdnMgl+nXMnuXIqEZg9nTI KDpyWie3Jnv7g9zlIL39T8Ygu6kc2NDISgjZ7y5IwcAVt+ONF0ck3dGqOWkwd4sfbcVF huiw== 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=PdVUbYdVmLlIKxvlsWpjolkRTGhn88OQckZovHVie98=; b=BenO2Mu1dRfHCpoD/sEMh3veFRbtHgM8r2GwlCgpl5O9q631oJ4oX2X4DT7aNHcaQt t99yDWRBlkjc50S93mMpWOdSjA+fmSg4Qlc9xzglGVlnRuWj60gD0f602qd05uS4tySM /rZk7HmaTqS5OAO9KgkaGUnYrFy/w3LtCZtFuHJMFPUTiRw28zR48nXfZt9oUIIcg+ab qToBFCn/F/94QDF0pLt7zmqqtwaMXtR68yd02vOHyOCRWRzIZGXPNE7mIDLGWvzBxwjQ aFwKl0sRnt6RNWs8AftszdEGfxDJR2CyhZQ+7NYU2MOomTGCavpXvF1yFd3+wnTYK1YL Y8LA== X-Gm-Message-State: AA+aEWYcpB8z/dMdhxXJ9VPhZ+Ma9r0rHDrmTVz8siqSqRbk+nQ7RlMX 6MbthEy+r4KJMWB7faCWd4j5hWUmKUU= X-Google-Smtp-Source: AFSGD/UgzjOim4tnBuLgyu6v4HSevCgUDCSc7xFvXf3Wt6H51PBVkVppjvdMjC6LsmFMwOF8gtnKow== X-Received: by 2002:a7b:c4cb:: with SMTP id g11mr12347562wmk.149.1545325643333; Thu, 20 Dec 2018 09:07:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:22 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:46 +0100 Message-Id: <7f6edf0902fe095391db3f090533a66b9f9e9507.1545325395.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 7/8] option: improve library documentation 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use doxygen to describe the main structure and describe a little more why it exists. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_option.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h index eea95e477..20be47d91 100644 --- a/lib/librte_eal/common/include/rte_option.h +++ b/lib/librte_eal/common/include/rte_option.h @@ -29,8 +29,12 @@ extern "C" { typedef int (*rte_option_cb)(void); -/* - * Structure describing the EAL command line option being registered. +/** + * Structure describing an EAL command line option dynamically registered. + * + * Common EAL options are mostly statically defined. + * Some libraries need additional options to be dynamically added. + * This structure describes such options. */ struct rte_option { TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */ From patchwork Thu Dec 20 17:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 49208 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BBB41BDCA; Thu, 20 Dec 2018 18:07:30 +0100 (CET) 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 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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