From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0061.outbound.protection.outlook.com [104.47.1.61]) by dpdk.org (Postfix) with ESMTP id CC1E51B898 for ; Fri, 13 Apr 2018 16:34:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Jwpx5g2f7w2/QDybxHHH9s1s4/AB5zpGuzJSL2/W9UI=; b=vk7rXUaEEpZPa+6KA8pO28/dyv1DBOuYoddol7CCzPc6ClI9d3PK7QVycAszjlpP6kv5OfReuhtB8dqRh4C1EhCTLCty40BVjJHCSlli1sRjgiGKaEzRr3J8OS5ex7Pre88cuAflJPiLCDZCLc4023VByIu5xklP5noMJmQ4UqE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from [10.232.14.39] (14.142.187.166) by VI1PR0402MB2781.eurprd04.prod.outlook.com (2603:10a6:800:ad::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Fri, 13 Apr 2018 14:34:13 +0000 To: Gaetan Rivet References: From: Shreyansh Jain Cc: dev@dpdk.org Message-ID: Date: Fri, 13 Apr 2018 20:19:16 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: KL1PR0601CA0016.apcprd06.prod.outlook.com (2603:1096:802:1::26) To VI1PR0402MB2781.eurprd04.prod.outlook.com (2603:10a6:800:ad::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB2781; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB2781; 3:0dTCykHYAz7dcr5s/QLh6y9VEG3UqEwxfsFjG/ulMuIKpWdguLtsjZUzqtKY4iv4iGtmlUNQNflfru1+h9rDoUTG7gs/Scf+X/rAZ+cCddYDcHa/778qsseJ9QkTUp39Anai1ypu6Axp9rYag3IkiVghvfp1syaugc3fXRUP4CjdHO/uwLQOH1CRstNexG2RgeQ9CfXjC+rVitkln4IMP78o2Rr5vnxONscdcJGH69Vmz9qrpivcporudXkjDpqX; 25:vTLCFvlRIyNcWWENApLriwbZoJrqviLHvVlKCy6OHyWSz9/cCnLireYJJIr3xw6mH2ENPlUDRoD+aj3IGl1eTO/Ye4Cg6cWxcAjoxIoPBK4eAIsItngvEHkq6N0JeuRvHPZ10INFYYoNkW9m1QNoExKoVE0q+JMwEGiaX/qsiE5fCJm5w+9HTRELHDlPc426MAAGa+SRCZfQXORXDt6NhxwK7Vf8yiRXrJZyu8Yrk4Tt/RHw2BXNbMWo9H2iQxv7Ii9NdQ9VI/D7mmmxCp/G9ZspApZPayOIq1jyVNX0NIUhV95RHCZOrd22v+JmXJM11lokgqF6mQ42h5sKKKEA6g==; 31:hZrEhJJ3udzbivfM1fdcLe92ancrXTfbyc2j23RqbbzG+3MTINg+9yMdu31+wDL2Jrj/1eMHi0BqM/dq0FWY6WKDXfrs4coZNOGZP1VjvvT78qfRNhvxxbA6viCihgi4LxfxtZRr2FbberpJbT67/TCdfV9NMzdlmCqX6vpySSdjotCxn+jjGIqwmbvfqA322WiviNmLaAtpBo3bHfUlGkFVUHuoG5cSAfAxWspydbU= X-MS-TrafficTypeDiagnostic: VI1PR0402MB2781: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB2781; 20:w37m4AhNGE9AdVRgesFb6w5vYNAZ/55OgIspxevjjRQd+wv5rDU875/mgZBLVfhjcm4hVz9a4gAzPP2rAeZ1wFJXvtCZJozLNyrvXbW4mlqf0CV+pTuDOFGW3tIjbfqUIyrmv3CgHSyBUCj7eXBABcbWqTL1dJbIVehfRUEv2QzqfDET64A/GwW4cht8FNKWAYllMKuqhaEbXlPkslxNNDDON7Nl6QbARgas+PheKpQgozXen8MAFppuAwykRTvgbUxmbObmN/hbWb9nJfWmRaFzzuweUIwh9uTp6FoKTMhX4rL1x/T92d8n6ZtyL1ikFviq0kaUYvrdKCaXgg+Da3hr74nk6t5Ytub6EBlVTsn6vhb5aBw61k+gmvrELu+SoixflUNYWUptYJQVMrRIPIYbtPd44MwDjmNBQU1DS/ojPfubLIf3mTJfMJxNYRC9zl6REtJHfCTiyOeEW+i2sYPLNiDUaxHE/iIEJKQPFidzWjcdHQU8bVYz+HB2Shm6; 4:1k/g9erfAeOor/3QUeMeenlcxaAcLF9OhVzzWYSdCIVC+egj7quBHPY12Clvtz9V59adHxQRkMP8jEMg+LtMZkskLhS2eVbCmfefBjImW/Q619PvgiMnekmsHcG4q3KbaM+tifjrkM+B0bz6H1t0CrvLPdRceV/QqstAT1ZdeVwljnr4huMVThInoNGJlKyAhzXtnznlaQ7Rik3GRD1ixz6riorvrOc4OG54HqV47Tzu4ETtS96+AsMEABDGLE7a4ME55g/Y1Jd2NIKbQSfXfA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231232)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0402MB2781; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB2781; X-Forefront-PRVS: 0641678E68 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6049001)(39380400002)(396003)(366004)(346002)(39860400002)(376002)(199004)(189003)(386003)(2486003)(2906002)(7736002)(76176011)(86362001)(59450400001)(55236004)(52146003)(446003)(305945005)(956004)(23676004)(476003)(50466002)(2616005)(64126003)(31696002)(11346002)(97736004)(105586002)(31686004)(229853002)(5009440100003)(106356001)(52116002)(8676002)(6246003)(36756003)(53936002)(230700001)(8936002)(6116002)(478600001)(3846002)(4326008)(6916009)(58126008)(26005)(6486002)(81166006)(81156014)(77096007)(67846002)(16526019)(186003)(65826007)(316002)(25786009)(5660300001)(66066001)(65956001)(65806001)(68736007)(16576012)(44832011)(486006)(47776003)(110426005)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB2781; H:[10.232.14.39]; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA0MDJNQjI3ODE7MjM6N0VSNEpmQTZzS3NQMVdFUDBMSmozampJ?= =?utf-8?B?bjcrT1RkL3VHNVdyZlFaT2d6NmFzU0hYbGJnSkxhUmpGMW5ITWp5SEJ1eHJV?= =?utf-8?B?d3hiVWNrRkswMElFS2YxMFNkaXVOTy9iQ09jN0xEUkN6WHpqa1drbXp6UTBy?= =?utf-8?B?ckdZcDhldFZMblZjdjR0eXRxOWdEdFVVWHZEQ25FaXgwU1hXYXQ5cldDWUlK?= =?utf-8?B?ampzY2lKV1VZMWxjY01vM2srejFKSVRONGZwZStvVE9KQ0poaGMzb3l0UThY?= =?utf-8?B?akpTNVBpL0lhbHgvQnRMMHFSczlydDY2WGJGalZFYWhCS1IwV0FSZGhqUHJl?= =?utf-8?B?NW00OFE4V0gvWjV3L2lCNnVaOUNGWHhnSFZaejgxTVJmTDBua0hCbmZDbE85?= =?utf-8?B?TFJIcDN6Q09iMjRKemxEaUg0UUY3cDBtUWlHQ3pnaUc5RDlaZ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l24WLIkfuw0FTqNanrlWV9a2rZKG2ZUE2AK5lYCP+tRFxdxN/iqyTSGC/Ieuzt5LYodH6WutXZwZQTcWSsGUOOUveVG/WN4TUE+taO+T7Pg5bYEdgTFE/fEKDT5Q X-MS-Office365-Filtering-Correlation-Id: de65dd96-173e-4181-7886-08d5a14ba19f X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2018 14:34:13.8682 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de65dd96-173e-4181-7886-08d5a14ba19f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2781 Subject: Re: [dpdk-dev] [PATCH v6 12/22] kvargs: add generic string matching callback 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: Fri, 13 Apr 2018 14:34:17 -0000 On Friday 13 April 2018 06:52 PM, Gaetan Rivet wrote: > This function can be used as a callback to > rte_kvargs_process. > > This should reduce code duplication. > > Signed-off-by: Gaetan Rivet > --- > lib/Makefile | 1 + > lib/librte_kvargs/rte_kvargs.c | 10 ++++++++++ > lib/librte_kvargs/rte_kvargs.h | 28 ++++++++++++++++++++++++++++ > lib/librte_kvargs/rte_kvargs_version.map | 7 +++++++ > 4 files changed, 46 insertions(+) > > diff --git a/lib/Makefile b/lib/Makefile > index 1b17526f7..4206485d3 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -5,6 +5,7 @@ include $(RTE_SDK)/mk/rte.vars.mk > > DIRS-y += librte_compat > DIRS-$(CONFIG_RTE_LIBRTE_KVARGS) += librte_kvargs > +DEPDIRS-librte_kvargs := librte_compat > DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal > DEPDIRS-librte_eal := librte_kvargs > DIRS-$(CONFIG_RTE_LIBRTE_PCI) += librte_pci > diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c > index 0a1abf579..6ee04cbb9 100644 > --- a/lib/librte_kvargs/rte_kvargs.c > +++ b/lib/librte_kvargs/rte_kvargs.c > @@ -180,3 +180,13 @@ rte_kvargs_parse(const char *args, const char * const valid_keys[]) > > return kvlist; > } > + > +__rte_experimental > +int > +rte_kvargs_strcmp(const char *key __rte_unused, > + const char *value, void *opaque) > +{ > + const char *str = opaque; > + > + return -strcmp(str, value); > +} > diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h > index 51b8120b8..c07c6fea5 100644 > --- a/lib/librte_kvargs/rte_kvargs.h > +++ b/lib/librte_kvargs/rte_kvargs.h > @@ -25,6 +25,8 @@ > extern "C" { > #endif > > +#include > + > /** Maximum number of key/value associations */ > #define RTE_KVARGS_MAX 32 > > @@ -121,6 +123,32 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist, > unsigned rte_kvargs_count(const struct rte_kvargs *kvlist, > const char *key_match); > > +/** > + * Generic kvarg handler for string comparison. > + * > + * This function can be used for a generic string comparison processing > + * on a list of kvargs. > + * > + * @param key > + * kvarg pair key. > + * > + * @param value > + * kvarg pair value. > + * > + * @param opaque > + * Opaque pointer to a string. > + * > + * @return > + * 0 if the strings match. > + * !0 otherwise or on error. > + * > + * Unless strcmp, comparison ordering is not kept. > + * In order for rte_kvargs_process to stop processing on match error, > + * a negative value is returned even if strcmp had returned a positive one. Is the above comment valid? > + return -strcmp(str, value); In case a negative is returned (when key opaque < value), this function would return a positive. So, effectively you have only reversed the values. Is that the expectation? In 21/22: --->8--- rte_kvargs_process --- for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; if (key_match == NULL || strcmp(pair->key, key_match) == 0) { if ((*handler)(pair->key, pair->value, opaque_arg) < 0) return -1; } } --->8--- This would only cause the opaque < value case to continue ahead but not the reverse. > + */ > +__rte_experimental > +int rte_kvargs_strcmp(const char *key, const char *value, void *opaque); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_kvargs/rte_kvargs_version.map b/lib/librte_kvargs/rte_kvargs_version.map > index 2030ec46c..e2f663a88 100644 > --- a/lib/librte_kvargs/rte_kvargs_version.map > +++ b/lib/librte_kvargs/rte_kvargs_version.map > @@ -8,3 +8,10 @@ DPDK_2.0 { > > local: *; > }; > + > +EXPERIMENTAL { > + global: > + > + rte_kvargs_strcmp; > + > +} DPDK_2.0; >