RE: [PATCH 03/61] test: use memcpy instead of rte_memcpy

Morten Brørup <[email protected]>
Newsgroups org.dpdk.dev
Message-ID <[email protected]>
> diff --git a/app/test/packet_burst_generator.c
> b/app/test/packet_burst_generator.c
> index 4c17737739..2f1d75c5bc 100644
> --- a/app/test/packet_burst_generator.c
> +++ b/app/test/packet_burst_generator.c
> @@ -31,20 +31,20 @@ copy_buf_to_pkt_segs(void *buf, unsigned len,
> struct rte_mbuf *pkt,
>  	copy_len = seg->data_len - offset;
>  	seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);
>  	while (len > copy_len) {
> -		rte_memcpy(seg_buf, buf, (size_t) copy_len);
> +		memcpy(seg_buf, buf, (size_t) copy_len);
>  		len -= copy_len;
>  		buf = ((char *) buf + copy_len);
>  		seg = seg->next;
>  		seg_buf = rte_pktmbuf_mtod(seg, void *);
>  	}
> -	rte_memcpy(seg_buf, buf, (size_t) len);
> +	memcpy(seg_buf, buf, (size_t) len);
>  }
> 
>  static inline void
>  copy_buf_to_pkt(void *buf, unsigned len, struct rte_mbuf *pkt,
> unsigned offset)
>  {
>  	if (offset + len <= pkt->data_len) {
> -		rte_memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset),
> buf,
> +		memcpy(rte_pktmbuf_mtod_offset(pkt, char *, offset), buf,
>  			   (size_t) len);

It looks like size is not constant in the above instances.

Try writing an intermediate wrapper using __rte_constant() to verify at build time.
Something like (assuming the return value is unused):

#define rte_memcpy_const_size(dst, src, n) \
do { \
	RTE_BUILD_BUG_ON(!__rte_constant(n)); \
	memcpy(dst, src, n); \
} while (0)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.