The copy of latency stat names could get truncated if in the future a new value is added. Add warning if that happens.
Signed-off-by: Stephen Hemminger <[email protected]> --- lib/latencystats/rte_latencystats.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c index f61d5a273f..0861d00c6b 100644 --- a/lib/latencystats/rte_latencystats.c +++ b/lib/latencystats/rte_latencystats.c @@ -405,9 +405,12 @@ rte_latencystats_get_names(struct rte_metric_name *names, uint16_t size) if (names == NULL || size < NUM_LATENCY_STATS) return NUM_LATENCY_STATS; - for (i = 0; i < NUM_LATENCY_STATS; i++) - strlcpy(names[i].name, lat_stats_strings[i].name, - sizeof(names[i].name)); + for (i = 0; i < NUM_LATENCY_STATS; i++) { + if (strlcpy(names[i].name, lat_stats_strings[i].name, sizeof(names[0].name)) + >= sizeof(names[0].name)) + LATENCY_STATS_LOG(NOTICE, "Latency metric '%s' too long", + lat_stats_strings[i].name); + } return NUM_LATENCY_STATS; } -- 2.51.0

