2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

dpdk: Use dynamic string for socket-mem construction.

No need to allocate memory and use 'strcat' direcly.
'dynamic-string' could do this for us.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
Ilya Maximets
2019-01-22 16:22:30 +03:00
committed by Ian Stokes
parent 409f724581
commit 9c68ca3432

View File

@@ -172,23 +172,20 @@ construct_dpdk_options(const struct smap *ovs_other_config,
static char *
construct_dpdk_socket_mem(void)
{
int numa;
const char *def_value = "1024";
int numa_nodes = ovs_numa_get_n_numas();
int numa, numa_nodes = ovs_numa_get_n_numas();
struct ds dpdk_socket_mem = DS_EMPTY_INITIALIZER;
if (numa_nodes == 0 || numa_nodes == OVS_NUMA_UNSPEC) {
numa_nodes = 1;
}
/* Allocate enough memory for digits, comma-sep and terminator. */
char *dpdk_socket_mem = xzalloc(numa_nodes * (strlen(def_value) + 1));
strcat(dpdk_socket_mem, def_value);
ds_put_cstr(&dpdk_socket_mem, def_value);
for (numa = 1; numa < numa_nodes; ++numa) {
strcat(dpdk_socket_mem, ",");
strcat(dpdk_socket_mem, def_value);
ds_put_format(&dpdk_socket_mem, ",%s", def_value);
}
return dpdk_socket_mem;
return ds_cstr(&dpdk_socket_mem);
}
#define MAX_DPDK_EXCL_OPTS 10