From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com
 [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id D0BEC58C3
 for <dev@dpdk.org>; Mon,  1 Jun 2015 15:34:10 +0200 (CEST)
Received: by padjw17 with SMTP id jw17so37261092pad.2
 for <dev@dpdk.org>; Mon, 01 Jun 2015 06:34:10 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-type:content-transfer-encoding;
 bh=Bl/3QwkSPVqdW1cD2I/XIUZtEVDwPK1HE7IEHHIhg54=;
 b=Xbu6VADF3GBuB7GA5O5K0XaCOpAAQCyg+WAqoOUEis29WX+leA3eSOd+MefMytoPh7
 6Xj4fKi5aIwNZzGeRSSzOIfVquMzm31GyRVnzwd1b6k6tuEJbEVf1Rmxv9GBWfJkSO//
 Rw4rFm9suK3T9Au99IAiGJwjqua9n7r1YLEv1z1sW3bRM9HppqUHH3N7/FRiWyl9rvHD
 SExKYo3zfxAGChhb33uja2MitWZkAq3pxktWtp6YQCBLFeEAHMkonPkJzyOP8nu0AGqC
 YYFq5M/a6DBNoO/CxWqRTz4sL87Qt0eDklpqYe6e00R0RD2wa5IhzD0IaMecFeDl9W5x
 jKdw==
X-Gm-Message-State: ALoCoQmQDBYHAMPvnDL/xP1AUo7ya+8lRXakH9BiMGWQtbbf5taHypJGCOG1yjm96q5YX9ym/S9U
X-Received: by 10.70.136.67 with SMTP id py3mr40694530pdb.112.1433165650202;
 Mon, 01 Jun 2015 06:34:10 -0700 (PDT)
Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net.
 [50.53.82.155])
 by mx.google.com with ESMTPSA id ia3sm14314720pbc.31.2015.06.01.06.34.09
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 01 Jun 2015 06:34:09 -0700 (PDT)
Date: Mon, 1 Jun 2015 06:34:12 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
Message-ID: <20150601063412.5805c879@urahara>
In-Reply-To: <1432914198-11812-2-git-send-email-maciejx.t.gajdzica@intel.com>
References: <1432914198-11812-1-git-send-email-maciejx.t.gajdzica@intel.com>
 <1432914198-11812-2-git-send-email-maciejx.t.gajdzica@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config
 files with new syntax
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Jun 2015 13:34:11 -0000

On Fri, 29 May 2015 17:43:08 +0200
Maciej Gajdzica <maciejx.t.gajdzica@intel.com> wrote:

> +/**
> + * Find object of name *name* in *obj_array* which is constant size array of
> + * elements that have field *name*.
> + *
> + * @param obj_array
> + *  Constant size array
> + * @param name
> + *  name of object to find.
> + * @return
> + *  Pointer to object in *obj_array* or NULL if not found.
> + */
> +#define APP_PARAM_FIND(obj_array, key)                          \
> +({                                                              \
> +	ssize_t obj_idx;                                            \
> +	const ssize_t obj_count = RTE_DIM(obj_array);               \
> +                                                                \
> +	for (obj_idx = 0; obj_idx < obj_count; obj_idx++) {         \
> +		if (!APP_PARAM_VALID(&((obj_array)[obj_idx])))          \
> +			continue;                                           \
> +			                                                    \
> +		if (strcmp(key, (obj_array)[obj_idx].name) == 0)        \
> +			break;                                              \
> +	}                                                           \
> +	obj_idx < obj_count ? obj_idx : -ENOENT;                    \
> +})

Converting all the functions to macro's is a step backwards in several ways.
 * macro's are hard to support
 * macro's lead to lots of programming errors
 * macro's look ugly

Why not use real functions, or make the example into C++ if you have
to do generic programming.