From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5ACF1A0C43; Tue, 19 Oct 2021 12:12:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7ACB041148; Tue, 19 Oct 2021 12:12:47 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 01D2840683; Tue, 19 Oct 2021 12:12:42 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10141"; a="209269423" X-IronPort-AV: E=Sophos;i="5.85,384,1624345200"; d="scan'208";a="209269423" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2021 03:12:41 -0700 X-IronPort-AV: E=Sophos;i="5.85,384,1624345200"; d="scan'208";a="494031851" Received: from unknown (HELO localhost.localdomain) ([10.240.183.65]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2021 03:12:38 -0700 From: zhihongx.peng@intel.com To: david.marchand@redhat.com, anatoly.burakov@intel.com, konstantin.ananyev@intel.com, stephen@networkplumber.org, cristian.dumitrescu@intel.com, john.mcnamara@intel.com, bruce.richardson@intel.com Cc: dev@dpdk.org, xueqin.lin@intel.com, Zhihong Peng , stable@dpdk.org Date: Tue, 19 Oct 2021 18:12:07 +0800 Message-Id: <20211019101207.1451058-4-zhihongx.peng@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211019101207.1451058-1-zhihongx.peng@intel.com> References: <20211015151110.1876850-4-zhihongx.peng@intel.com> <20211019101207.1451058-1-zhihongx.peng@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v11 4/4] performance-thread: Fix cross compilation failed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Zhihong Peng The gcc(arm-linux-gcc) will check code more stricter when ASan enabled. "strncpy specified bound XX equals destination size" error occurs here. Fixes: 116819b9ed0d ("examples/performance-thread: add lthread subsystem") Cc: stable@dpdk.org Signed-off-by: Xueqin Lin Signed-off-by: Zhihong Peng --- v11: Use rte_strlcpy to replace strncpy. --- examples/performance-thread/common/lthread.c | 4 ++-- examples/performance-thread/common/lthread_cond.c | 6 +++--- examples/performance-thread/common/lthread_mutex.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/performance-thread/common/lthread.c b/examples/performance-thread/common/lthread.c index 3f1f48db43..7949beb8e2 100644 --- a/examples/performance-thread/common/lthread.c +++ b/examples/performance-thread/common/lthread.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -463,6 +464,5 @@ void lthread_set_funcname(const char *f) { struct lthread *lt = THIS_LTHREAD; - strncpy(lt->funcname, f, sizeof(lt->funcname)); - lt->funcname[sizeof(lt->funcname)-1] = 0; + rte_strlcpy(lt->funcname, f, sizeof(lt->funcname)); } diff --git a/examples/performance-thread/common/lthread_cond.c b/examples/performance-thread/common/lthread_cond.c index cdcc7a7b5a..398735c192 100644 --- a/examples/performance-thread/common/lthread_cond.c +++ b/examples/performance-thread/common/lthread_cond.c @@ -20,6 +20,7 @@ #include #include +#include #include "lthread_api.h" #include "lthread_diag_api.h" @@ -57,10 +58,9 @@ lthread_cond_init(char *name, struct lthread_cond **cond, } if (name == NULL) - strncpy(c->name, "no name", sizeof(c->name)); + rte_strlcpy(c->name, "no name", sizeof(c->name)); else - strncpy(c->name, name, sizeof(c->name)); - c->name[sizeof(c->name)-1] = 0; + rte_strlcpy(c->name, name, sizeof(c->name)); c->root_sched = THIS_SCHED; diff --git a/examples/performance-thread/common/lthread_mutex.c b/examples/performance-thread/common/lthread_mutex.c index 01da6cad4f..1911e5ac67 100644 --- a/examples/performance-thread/common/lthread_mutex.c +++ b/examples/performance-thread/common/lthread_mutex.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "lthread_api.h" #include "lthread_int.h" @@ -52,10 +53,9 @@ lthread_mutex_init(char *name, struct lthread_mutex **mutex, } if (name == NULL) - strncpy(m->name, "no name", sizeof(m->name)); + rte_strlcpy(m->name, "no name", sizeof(m->name)); else - strncpy(m->name, name, sizeof(m->name)); - m->name[sizeof(m->name)-1] = 0; + rte_strlcpy(m->name, name, sizeof(m->name)); m->root_sched = THIS_SCHED; m->owner = NULL; -- 2.25.1