[dpdk-dev] fix rte_memcpy() macro: avoid unused value warning

Message ID 1418662502-16406-1-git-send-email-michalx.k.jastrzebski@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Michal Jastrzebski Dec. 15, 2014, 4:55 p.m. UTC
  From: Pawel Wodkowski <pawelx.wodkowski@intel.com>

This change use statements in expressions C extension provided by gcc to avoid
'value computed is not used' warning/error when size is not known at compile
time.

Comments on possible side effects are welcome an tests are welcome.

Reported-by: Qiu, Michael <michael.qiu@intel.com>
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
---
 .../common/include/arch/x86/rte_memcpy.h           |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Michael Qiu Dec. 16, 2014, 1:57 a.m. UTC | #1
On 12/16/2014 12:55 AM, Michal Jastrzebski wrote:
> From: Pawel Wodkowski <pawelx.wodkowski@intel.com>
>
> This change use statements in expressions C extension provided by gcc to avoid
> 'value computed is not used' warning/error when size is not known at compile
> time.
>
> Comments on possible side effects are welcome an tests are welcome.
>
> Reported-by: Qiu, Michael <michael.qiu@intel.com>
> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> ---
>  .../common/include/arch/x86/rte_memcpy.h           |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> index 290c5cd..c3e8b81 100644
> --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
> @@ -169,9 +169,9 @@ rte_mov256(uint8_t *dst, const uint8_t *src)
>  }
>  
>  #define rte_memcpy(dst, src, n)              \
> -	((__builtin_constant_p(n)) ?          \
> +	({ (__builtin_constant_p(n)) ?          \
>  	memcpy((dst), (src), (n)) :          \
> -	rte_memcpy_func((dst), (src), (n)))
> +	rte_memcpy_func((dst), (src), (n)); })
>  
>  static inline void *
>  rte_memcpy_func(void *dst, const void *src, size_t n)

Acked-by: Qiu, Michael <michael.qiu@intel.com>
  
Thomas Monjalon Dec. 16, 2014, 11:50 p.m. UTC | #2
2014-12-16 01:57, Qiu, Michael:
> On 12/16/2014 12:55 AM, Michal Jastrzebski wrote:
> > From: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> >
> > This change use statements in expressions C extension provided by gcc to avoid
> > 'value computed is not used' warning/error when size is not known at compile
> > time.
> >
> > Comments on possible side effects are welcome an tests are welcome.
> >
> > Reported-by: Qiu, Michael <michael.qiu@intel.com>
> > Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
> 
> Acked-by: Qiu, Michael <michael.qiu@intel.com>

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied with a PPC equivalent.

Thanks
  

Patch

diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
index 290c5cd..c3e8b81 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -169,9 +169,9 @@  rte_mov256(uint8_t *dst, const uint8_t *src)
 }
 
 #define rte_memcpy(dst, src, n)              \
-	((__builtin_constant_p(n)) ?          \
+	({ (__builtin_constant_p(n)) ?          \
 	memcpy((dst), (src), (n)) :          \
-	rte_memcpy_func((dst), (src), (n)))
+	rte_memcpy_func((dst), (src), (n)); })
 
 static inline void *
 rte_memcpy_func(void *dst, const void *src, size_t n)