summaryrefslogtreecommitdiff
path: root/lib/dpdk.c
diff options
context:
space:
mode:
authorDavid Marchand <david.marchand@redhat.com>2019-09-06 13:26:02 +0200
committerIan Stokes <ian.stokes@intel.com>2019-09-26 09:28:25 +0100
commitd0d1a76eac10dff8b2eb10bc5ff35b65eacd7234 (patch)
tree284bbc2088975076ad534914ea1397aca65b2eec /lib/dpdk.c
parent892545b953d23e29da8f556937f7ea66d0e85e28 (diff)
downloadopenvswitch-d0d1a76eac10dff8b2eb10bc5ff35b65eacd7234.tar.gz
dpdk: Remove unneeded log message copy.
No need to duplicate and null-terminate the passed buffer. We can directly give it to the vlog subsystem using a dynamic precision in the format string. Signed-off-by: David Marchand <david.marchand@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'lib/dpdk.c')
-rw-r--r--lib/dpdk.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/dpdk.c b/lib/dpdk.c
index 6f297d918..f90cda75a 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -232,34 +232,32 @@ construct_dpdk_args(const struct smap *ovs_other_config, struct svec *args)
static ssize_t
dpdk_log_write(void *c OVS_UNUSED, const char *buf, size_t size)
{
- char *str = xmemdup0(buf, size);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(600, 600);
static struct vlog_rate_limit dbg_rl = VLOG_RATE_LIMIT_INIT(600, 600);
switch (rte_log_cur_msg_loglevel()) {
case RTE_LOG_DEBUG:
- VLOG_DBG_RL(&dbg_rl, "%s", str);
+ VLOG_DBG_RL(&dbg_rl, "%.*s", (int) size, buf);
break;
case RTE_LOG_INFO:
case RTE_LOG_NOTICE:
- VLOG_INFO_RL(&rl, "%s", str);
+ VLOG_INFO_RL(&rl, "%.*s", (int) size, buf);
break;
case RTE_LOG_WARNING:
- VLOG_WARN_RL(&rl, "%s", str);
+ VLOG_WARN_RL(&rl, "%.*s", (int) size, buf);
break;
case RTE_LOG_ERR:
- VLOG_ERR_RL(&rl, "%s", str);
+ VLOG_ERR_RL(&rl, "%.*s", (int) size, buf);
break;
case RTE_LOG_CRIT:
case RTE_LOG_ALERT:
case RTE_LOG_EMERG:
- VLOG_EMER("%s", str);
+ VLOG_EMER("%.*s", (int) size, buf);
break;
default:
OVS_NOT_REACHED();
}
- free(str);
return size;
}