[dpdk-dev] [PATCH 01/11] ip_pipeline: add parsing for config files with new syntax
Stephen Hemminger
stephen at networkplumber.org
Mon Jun 1 15:34:12 CEST 2015
On Fri, 29 May 2015 17:43:08 +0200
Maciej Gajdzica <maciejx.t.gajdzica at 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.
More information about the dev
mailing list