From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id 43C16695D for ; Tue, 28 Jan 2014 17:06:06 +0100 (CET) Received: by mail-wg0-f45.google.com with SMTP id n12so1159252wgh.0 for ; Tue, 28 Jan 2014 08:07:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s0vnrWFQ8/gd8dzC8WVs6ZrIcD5LHu38QzTjCE3sZn4=; b=MRY1arFXpYsOb+ZzfnGFQ2PiMhbLcqqyzHknvA5uWkoF0KuBJloSZGSGNmTdsf/G+e FCP6n6muKH9x59KA0ZHphT596AyXYKUqQ9S/sZZEXdT5gMKBuIcN+4j2pvAC0MjY6bBJ 9qZuVP/5awiQGUiljTKAYQqM197uQ/0DQiQEWDdBsf7Ezi4u1wU3AfG1ZZn4m1H0r3zR DSkYTg3ScNxqegd4un3hSnF1jxvMJbOgi2pXvrKvcp0i4L1hstWtD57JqbTTbUNeFLi5 z3dgTS0Rv/1QX4jbcYO4PoOxRh3GlHsJk1O6VKCKZi/lMutuGuhsDXOMRbF3CUpfiS+5 w5Eg== X-Gm-Message-State: ALoCoQkpD9s28jbPn7JORPUleMAY5zHNlw0ZUZCyG0oMUpnhTEtnfjBaj7vsewMWgSAIjL5QrrJ4 X-Received: by 10.195.13.113 with SMTP id ex17mr1671244wjd.0.1390925244658; Tue, 28 Jan 2014 08:07:24 -0800 (PST) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id d6sm36407821wic.9.2014.01.28.08.07.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 08:07:23 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Tue, 28 Jan 2014 17:06:43 +0100 Message-Id: <1390925204-10800-11-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1390925204-10800-1-git-send-email-olivier.matz@6wind.com> References: <1390925204-10800-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 10/11] kvargs: make the NULL key to match all entries 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: , X-List-Received-Date: Tue, 28 Jan 2014 16:06:06 -0000 In rte_kvargs_process() and rte_kvargs_count(), if the key_match argument is NULL, process all entries. Signed-off-by: Olivier Matz --- lib/librte_kvargs/rte_kvargs.c | 4 ++-- lib/librte_kvargs/rte_kvargs.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 1ff7056..3d65437 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -139,7 +139,7 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match) ret = 0; for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; - if (strcmp(pair->key, key_match) == 0) + if (key_match == NULL || strcmp(pair->key, key_match) == 0) ret++; } @@ -160,7 +160,7 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; - if (strcmp(pair->key, key_match) == 0) { + if (key_match == NULL || strcmp(pair->key, key_match) == 0) { if ((*handler)(pair->key, pair->value, opaque_arg) < 0) return -1; } diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h index c080c06..e375547 100644 --- a/lib/librte_kvargs/rte_kvargs.h +++ b/lib/librte_kvargs/rte_kvargs.h @@ -120,7 +120,8 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); * @param kvlist * The rte_kvargs structure * @param key_match - * The key on which the handler should be called + * The key on which the handler should be called, or NULL to process handler + * on all associations * @param handler * The function to call for each matching key * @param opaque_arg @@ -139,7 +140,7 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist, * @param kvlist * The rte_kvargs structure * @param key_match - * The key that should match + * The key that should match, or NULL to count all associations * @return * The number of entries -- 1.8.4.rc3