From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v1 01/10] app/test: introduce resources for tests Date: Fri, 06 May 2016 16:01:08 +0200 Message-ID: <7154696.NNSjZHJaDi@xps13> References: <1462531720-26217-1-git-send-email-viktorin@rehivetech.com> <1462531720-26217-2-git-send-email-viktorin@rehivetech.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, Bruce Richardson , David Marchand To: Jan Viktorin Return-path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id 0F7F369FF for ; Fri, 6 May 2016 16:01:10 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id a17so79664152wme.0 for ; Fri, 06 May 2016 07:01:10 -0700 (PDT) In-Reply-To: <1462531720-26217-2-git-send-email-viktorin@rehivetech.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2016-05-06 12:48, Jan Viktorin: > --- /dev/null > +++ b/app/test/resource.h > @@ -0,0 +1,61 @@ > +/*- > + * BSD LICENSE [...] > + */ Please include a multi-line comment here to explain what is a resource and why it is needed. > + > +#ifndef _RESOURCE_H_ > +#define _RESOURCE_H_ > + |...] |> + > +TAILQ_HEAD(resource_list, resource); > +extern struct resource_list resource_list; Why extern? > + > +struct resource { > + const char *name; > + const char *beg; begin? Bruce is removing some megabytes from lpm tests, so we have some room for field names ;) > + const char *end; > + TAILQ_ENTRY(resource) next; > +}; > + > +static inline size_t resource_size(const struct resource *r) Why inline? It could be in .c > +{ > + return r->end - r->beg; > +} > + > +const struct resource *resource_find(const char *name); > + > +void __resource_register(struct resource *r); A comment is needed to explain the role of this function. Why a double underscore? > +#define REGISTER_RESOURCE(_n, _b, _e) \ I'm not a big fan of the underscores. > +static struct resource linkres_ ##_n = { \ > + .name = RTE_STR(_n), \ > + .beg = _b, \ > + .end = _e, \ > +}; \ > +__REGISTER_RESOURCE(linkres_ ##_n) Please avoid nested macros. > +#define __REGISTER_RESOURCE(name) \ > +static void __attribute__((constructor,used)) resinitfn_ ##name(void); \ Why declaring the function just before its implementation? > +static void __attribute__((constructor,used)) resinitfn_ ##name(void) \ > +{ \ > + __resource_register(&name); \ > +}