From c3f109f91eadff77c4277c3a698452dda83b5d2f Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 24 Mar 2017 15:56:09 -0700 Subject: [PATCH] trace: Increase the size of trace name According to the analysis, the largest name size is 24 not including '\0' (NVMF_RDMA_WRITE_COMPLETE), so change the the size of name. Also add a check to avoid the str exceeding our defined name size. Change-Id: Iddf2cb52a3f5358306a59fc66bb997fa8098cde0 Signed-off-by: Ziye Yang --- include/spdk/trace.h | 2 +- lib/trace/trace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spdk/trace.h b/include/spdk/trace.h index c90e2228c..f7a8181dd 100644 --- a/include/spdk/trace.h +++ b/include/spdk/trace.h @@ -78,7 +78,7 @@ struct spdk_trace_object { #define SPDK_TPOINT_ID(group, tpoint) ((group * 64) + tpoint) struct spdk_trace_tpoint { - char name[24]; + char name[44]; char short_name[4]; uint16_t tpoint_id; uint8_t owner_type; diff --git a/lib/trace/trace.c b/lib/trace/trace.c index 9052f3c47..bf7f80fd8 100644 --- a/lib/trace/trace.c +++ b/lib/trace/trace.c @@ -255,8 +255,8 @@ spdk_trace_register_description(const char *name, const char *short_name, tpoint = &g_trace_histories->tpoint[tpoint_id]; assert(tpoint->tpoint_id == 0); - strncpy(tpoint->name, name, sizeof(tpoint->name)); - strncpy(tpoint->short_name, short_name, sizeof(tpoint->short_name)); + snprintf(tpoint->name, sizeof(tpoint->name), "%s", name); + snprintf(tpoint->short_name, sizeof(tpoint->short_name), "%s", short_name); tpoint->tpoint_id = tpoint_id; tpoint->object_type = object_type; tpoint->owner_type = owner_type;