From patchwork Thu May 19 14:48:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 12903 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 5A2C4ADA6; Thu, 19 May 2016 16:51:05 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 115EAAD97 for ; Thu, 19 May 2016 16:51:01 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 19 May 2016 07:49:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,334,1459839600"; d="scan'208";a="984604144" Received: from sie-lab-214-251.ir.intel.com (HELO silpixa373510.ir.intel.com) ([10.237.214.251]) by fmsmga002.fm.intel.com with ESMTP; 19 May 2016 07:49:04 -0700 From: David Hunt To: dev@dpdk.org Cc: olivier.matz@6wind.com, David Hunt Date: Thu, 19 May 2016 15:48:54 +0100 Message-Id: <1463669335-30378-3-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463669335-30378-1-git-send-email-david.hunt@intel.com> References: <1462472982-49782-1-git-send-email-david.hunt@intel.com> <1463669335-30378-1-git-send-email-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 2/3] mempool: make declaration of handler structs const 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For security, any data structure with function pointers should be const Signed-off-by: David Hunt --- lib/librte_mempool/rte_mempool.h | 2 +- lib/librte_mempool/rte_mempool_default.c | 8 ++++---- lib/librte_mempool/rte_mempool_handler.c | 2 +- lib/librte_mempool/rte_mempool_stack.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index ed2c110..baa5f48 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -491,7 +491,7 @@ rte_mempool_set_handler(struct rte_mempool *mp, const char *name); * - >=0: Sucess; return the index of the handler in the table. * - <0: Error (errno) */ -int rte_mempool_handler_register(struct rte_mempool_handler *h); +int rte_mempool_handler_register(const struct rte_mempool_handler *h); /** * Macro to statically register an external pool handler. diff --git a/lib/librte_mempool/rte_mempool_default.c b/lib/librte_mempool/rte_mempool_default.c index a6ac65a..764f772 100644 --- a/lib/librte_mempool/rte_mempool_default.c +++ b/lib/librte_mempool/rte_mempool_default.c @@ -105,7 +105,7 @@ common_ring_free(void *p) rte_ring_free((struct rte_ring *)p); } -static struct rte_mempool_handler handler_mp_mc = { +static const struct rte_mempool_handler handler_mp_mc = { .name = "ring_mp_mc", .alloc = common_ring_alloc, .free = common_ring_free, @@ -114,7 +114,7 @@ static struct rte_mempool_handler handler_mp_mc = { .get_count = common_ring_get_count, }; -static struct rte_mempool_handler handler_sp_sc = { +static const struct rte_mempool_handler handler_sp_sc = { .name = "ring_sp_sc", .alloc = common_ring_alloc, .free = common_ring_free, @@ -123,7 +123,7 @@ static struct rte_mempool_handler handler_sp_sc = { .get_count = common_ring_get_count, }; -static struct rte_mempool_handler handler_mp_sc = { +static const struct rte_mempool_handler handler_mp_sc = { .name = "ring_mp_sc", .alloc = common_ring_alloc, .free = common_ring_free, @@ -132,7 +132,7 @@ static struct rte_mempool_handler handler_mp_sc = { .get_count = common_ring_get_count, }; -static struct rte_mempool_handler handler_sp_mc = { +static const struct rte_mempool_handler handler_sp_mc = { .name = "ring_sp_mc", .alloc = common_ring_alloc, .free = common_ring_free, diff --git a/lib/librte_mempool/rte_mempool_handler.c b/lib/librte_mempool/rte_mempool_handler.c index 78611f8..eab1e69 100644 --- a/lib/librte_mempool/rte_mempool_handler.c +++ b/lib/librte_mempool/rte_mempool_handler.c @@ -45,7 +45,7 @@ struct rte_mempool_handler_table rte_mempool_handler_table = { /* add a new handler in rte_mempool_handler_table, return its index */ int -rte_mempool_handler_register(struct rte_mempool_handler *h) +rte_mempool_handler_register(const struct rte_mempool_handler *h) { struct rte_mempool_handler *handler; int16_t handler_idx; diff --git a/lib/librte_mempool/rte_mempool_stack.c b/lib/librte_mempool/rte_mempool_stack.c index 6e25028..ad49436 100644 --- a/lib/librte_mempool/rte_mempool_stack.c +++ b/lib/librte_mempool/rte_mempool_stack.c @@ -133,7 +133,7 @@ common_stack_free(void *p) rte_free(p); } -static struct rte_mempool_handler handler_stack = { +static const struct rte_mempool_handler handler_stack = { .name = "stack", .alloc = common_stack_alloc, .free = common_stack_free,