[dpdk-dev,v2,2/3] mempool: make declaration of handler structs const
Commit Message
For security, any data structure with function pointers should be const
Signed-off-by: David Hunt <david.hunt@intel.com>
---
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(-)
Comments
Hi David,
On 05/19/2016 04:48 PM, David Hunt wrote:
> For security, any data structure with function pointers should be const
>
> Signed-off-by: David Hunt <david.hunt@intel.com>
I think this should be merged in the patchset adding the mempool
handler feature.
On 5/23/2016 1:55 PM, Olivier Matz wrote:
> Hi David,
>
> On 05/19/2016 04:48 PM, David Hunt wrote:
>> For security, any data structure with function pointers should be const
> I think this should be merged in the patchset adding the mempool
> handler feature.
Agreed, I'm working on that now, merging it in with some changes
suggested by Jan on the other patch.
Thanks,
David.
@@ -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.
@@ -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,
@@ -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;
@@ -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,