[dpdk-stable] [PATCH v10 4/4] performance-thread: Fix cross compilation failed

Peng, ZhihongX zhihongx.peng at intel.com
Tue Oct 19 08:02:03 CEST 2021


> -----Original Message-----
> From: Peng, ZhihongX <zhihongx.peng at intel.com>
> Sent: Friday, October 15, 2021 11:11 PM
> To: david.marchand at redhat.com; Burakov, Anatoly
> <anatoly.burakov at intel.com>; Ananyev, Konstantin
> <konstantin.ananyev at intel.com>; stephen at networkplumber.org;
> Dumitrescu, Cristian <cristian.dumitrescu at intel.com>; Mcnamara, John
> <john.mcnamara at intel.com>
> Cc: dev at dpdk.org; Lin, Xueqin <xueqin.lin at intel.com>; Peng, ZhihongX
> <ZhihongX.Peng at intel.com>; stable at dpdk.org
> Subject: [PATCH v10 4/4] performance-thread: Fix cross compilation failed
> 
> From: Zhihong Peng <zhihongx.peng at intel.com>
> 
> 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 at dpdk.org
> 
> Signed-off-by: Xueqin Lin <xueqin.lin at intel.com>
> Signed-off-by: Zhihong Peng <zhihongx.peng at intel.com>
> ---
>  examples/performance-thread/common/lthread.c       | 2 +-
>  examples/performance-thread/common/lthread_cond.c  | 4 ++--
> examples/performance-thread/common/lthread_mutex.c | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/examples/performance-thread/common/lthread.c
> b/examples/performance-thread/common/lthread.c
> index 3f1f48db43..dd4b3b27ee 100644
> --- a/examples/performance-thread/common/lthread.c
> +++ b/examples/performance-thread/common/lthread.c
> @@ -463,6 +463,6 @@ void lthread_set_funcname(const char *f)  {
>  	struct lthread *lt = THIS_LTHREAD;
> 
> -	strncpy(lt->funcname, f, sizeof(lt->funcname));
> +	strncpy(lt->funcname, f, sizeof(lt->funcname) - 1);
>  	lt->funcname[sizeof(lt->funcname)-1] = 0;  } diff --git
> a/examples/performance-thread/common/lthread_cond.c
> b/examples/performance-thread/common/lthread_cond.c
> index cdcc7a7b5a..6ec8bc7e82 100644
> --- a/examples/performance-thread/common/lthread_cond.c
> +++ b/examples/performance-thread/common/lthread_cond.c
> @@ -57,9 +57,9 @@ lthread_cond_init(char *name, struct lthread_cond
> **cond,
>  	}
> 
>  	if (name == NULL)
> -		strncpy(c->name, "no name", sizeof(c->name));
> +		strncpy(c->name, "no name", sizeof(c->name) - 1);
>  	else
> -		strncpy(c->name, name, sizeof(c->name));
> +		strncpy(c->name, name, sizeof(c->name) - 1);
>  	c->name[sizeof(c->name)-1] = 0;
> 
>  	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..7e5da609b1 100644
> --- a/examples/performance-thread/common/lthread_mutex.c
> +++ b/examples/performance-thread/common/lthread_mutex.c
> @@ -52,9 +52,9 @@ lthread_mutex_init(char *name, struct lthread_mutex
> **mutex,
>  	}
> 
>  	if (name == NULL)
> -		strncpy(m->name, "no name", sizeof(m->name));
> +		strncpy(m->name, "no name", sizeof(m->name) - 1);
>  	else
> -		strncpy(m->name, name, sizeof(m->name));
> +		strncpy(m->name, name, sizeof(m->name) - 1);
>  	m->name[sizeof(m->name)-1] = 0;
> 
>  	m->root_sched = THIS_SCHED;
> --
> 2.25.1

Hi, John

Can you give me an ack?

Thanks!


More information about the stable mailing list