X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mbuf%2Frte_mbuf_pool_ops.c;h=f0e87a1412ce782c59a8b525540e42a1042acca2;hb=f8eb26dda8bfc806ff71f65966dc17210686fc20;hp=385fc438f432aceaf91a4b8ddb98a5370d9e1573;hpb=77b7b81e32e94e79d2a65b259769ae11725be8bf;p=dpdk.git diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c index 385fc438f4..f0e87a1412 100644 --- a/lib/librte_mbuf/rte_mbuf_pool_ops.c +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c @@ -9,12 +9,15 @@ #include #include -int __rte_experimental +int rte_mbuf_set_platform_mempool_ops(const char *ops_name) { const struct rte_memzone *mz; - if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE); + if (len == 0) + return -EINVAL; + if (len == RTE_MEMPOOL_OPS_NAMESIZE) return -ENAMETOOLONG; mz = rte_memzone_lookup("mbuf_platform_pool_ops"); @@ -23,7 +26,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name) RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0); if (mz == NULL) return -rte_errno; - strncpy(mz->addr, ops_name, strlen(ops_name)); + strcpy(mz->addr, ops_name); return 0; } else if (strcmp(mz->addr, ops_name) == 0) { return 0; @@ -35,7 +38,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name) return -EEXIST; } -const char * __rte_experimental +const char * rte_mbuf_platform_mempool_ops(void) { const struct rte_memzone *mz; @@ -46,12 +49,15 @@ rte_mbuf_platform_mempool_ops(void) return mz->addr; } -int __rte_experimental +int rte_mbuf_set_user_mempool_ops(const char *ops_name) { const struct rte_memzone *mz; - if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE); + if (len == 0) + return -EINVAL; + if (len == RTE_MEMPOOL_OPS_NAMESIZE) return -ENAMETOOLONG; mz = rte_memzone_lookup("mbuf_user_pool_ops"); @@ -62,24 +68,24 @@ rte_mbuf_set_user_mempool_ops(const char *ops_name) return -rte_errno; } - strncpy(mz->addr, ops_name, strlen(ops_name)); + strcpy(mz->addr, ops_name); return 0; } -const char * __rte_experimental +const char * rte_mbuf_user_mempool_ops(void) { const struct rte_memzone *mz; mz = rte_memzone_lookup("mbuf_user_pool_ops"); if (mz == NULL) - return rte_eal_mbuf_default_mempool_ops(); + return rte_eal_mbuf_user_pool_ops(); return mz->addr; } /* Return mbuf pool ops name */ -const char * __rte_experimental +const char * rte_mbuf_best_mempool_ops(void) { /* User defined mempool ops takes the priority */