* [dpdk-dev] error: value computed is not used
@ 2014-12-08 9:05 Qiu, Michael
2014-12-08 11:00 ` Wodkowski, PawelX
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Qiu, Michael @ 2014-12-08 9:05 UTC (permalink / raw)
To: dev
Hi all,
My platform is:
uname -a
Linux suse-11-sp3 3.0.77-0.11-xen #1 SMP Tue Mar 11 16:48:56 CST 2014
x86_64 x86_64 x86_64 GNU/Linux
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5
--enable-ssp --disable-libssp --disable-plugin
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64
--with-system-zlib --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.5
--enable-linux-futex --without-system-libunwind --enable-gold
--with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic
--build=x86_64-suse-linux
Thread model: posix
gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585] (SUSE Linux)
When I try to compile the source code to x86_64 linuxapp, I got this
error message:
lib/librte_pmd_enic/enic_main.c: In function ‘enic_set_rsskey’:
lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
I dig out that, it was ome issue of the macros rte_memcpy()
#define rte_memcpy(dst, src, n) \
((__builtin_constant_p(n)) ? \
memcpy((dst), (src), (n)) : \
rte_memcpy_func((dst), (src), (n)))
When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
know that it was incorrect, just a experiment).
But I try to use inline function instead of macros:
static inline void * rte_memcpy(void *dst, const void *src, size_t n)
{
return __builtin_constant_p(n) ? memcpy(dst, src, n) :
rte_memcpy_func(dst, src, n);
}
It will pass:), and works, this could be one potential workaround fix.
Who knows why? The root cause is what?
I've no idea about this.
Thanks,
Michael
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 9:05 [dpdk-dev] error: value computed is not used Qiu, Michael
@ 2014-12-08 11:00 ` Wodkowski, PawelX
2014-12-08 15:23 ` Qiu, Michael
2014-12-09 9:19 ` Qiu, Michael
2014-12-10 9:26 ` Qiu, Michael
2 siblings, 1 reply; 18+ messages in thread
From: Wodkowski, PawelX @ 2014-12-08 11:00 UTC (permalink / raw)
To: Qiu, Michael, dev
> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
>
> I dig out that, it was ome issue of the macros rte_memcpy()
> #define rte_memcpy(dst, src, n) \
> ((__builtin_constant_p(n)) ? \
> memcpy((dst), (src), (n)) : \
> rte_memcpy_func((dst), (src), (n)))
>
> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> know that it was incorrect, just a experiment).
>
> But I try to use inline function instead of macros:
> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> {
> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> rte_memcpy_func(dst, src, n);
> }
>
> It will pass:), and works, this could be one potential workaround fix.
>
> Who knows why? The root cause is what?
>
> I've no idea about this.
>
I got the same issue while ago. I don't remember exactly everything
but my conclusion was that there was some bug in compiler. I think,
when 'n' I constant and/or small compiler is inlining memcpy and throwing
everything else (including returned value). In that case error is not
produced (I think this is a bug in compiler). In other case it is computing
some value calling memcpy or rte_ memcpy and you should at least
explicitly throw it away by casting to void. I like solution with static
inline but someone else should spoke about possible side effects.
Pawel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 11:00 ` Wodkowski, PawelX
@ 2014-12-08 15:23 ` Qiu, Michael
2014-12-08 15:26 ` Wodkowski, PawelX
0 siblings, 1 reply; 18+ messages in thread
From: Qiu, Michael @ 2014-12-08 15:23 UTC (permalink / raw)
To: Wodkowski, PawelX, dev
On 2014/12/8 19:00, Wodkowski, PawelX wrote:
>> lib/librte_pmd_enic/enic_main.c: In function ‘enic_set_rsskey’:
>> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
>>
>> I dig out that, it was ome issue of the macros rte_memcpy()
>> #define rte_memcpy(dst, src, n) \
>> ((__builtin_constant_p(n)) ? \
>> memcpy((dst), (src), (n)) : \
>> rte_memcpy_func((dst), (src), (n)))
>>
>> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
>> know that it was incorrect, just a experiment).
>>
>> But I try to use inline function instead of macros:
>> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
>> {
>> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
>> rte_memcpy_func(dst, src, n);
>> }
>>
>> It will pass:), and works, this could be one potential workaround fix.
>>
>> Who knows why? The root cause is what?
>>
>> I've no idea about this.
>>
> I got the same issue while ago. I don't remember exactly everything
> but my conclusion was that there was some bug in compiler. I think,
> when 'n' I constant and/or small compiler is inlining memcpy and throwing
> everything else (including returned value). In that case error is not
> produced (I think this is a bug in compiler). In other case it is computing
> some value calling memcpy or rte_ memcpy and you should at least
> explicitly throw it away by casting to void. I like solution with static
Actually, I try to pass "n" as a Int value like 4, it still report this
error :)
> inline but someone else should spoke about possible side effects.
Yes, but as I know inline is better than macros.
Thanks,
Michael
>
> Pawel
>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 15:23 ` Qiu, Michael
@ 2014-12-08 15:26 ` Wodkowski, PawelX
2014-12-15 10:54 ` Thomas Monjalon
0 siblings, 1 reply; 18+ messages in thread
From: Wodkowski, PawelX @ 2014-12-08 15:26 UTC (permalink / raw)
To: Qiu, Michael, dev
> -----Original Message-----
> From: Qiu, Michael
> Sent: Monday, December 08, 2014 4:24 PM
> To: Wodkowski, PawelX; dev@dpdk.org
> Subject: Re: error: value computed is not used
>
> On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> >>
> >> I dig out that, it was ome issue of the macros rte_memcpy()
> >> #define rte_memcpy(dst, src, n) \
> >> ((__builtin_constant_p(n)) ? \
> >> memcpy((dst), (src), (n)) : \
> >> rte_memcpy_func((dst), (src), (n)))
> >>
> >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> >> know that it was incorrect, just a experiment).
> >>
> >> But I try to use inline function instead of macros:
> >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> >> {
> >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> >> rte_memcpy_func(dst, src, n);
> >> }
> >>
> >> It will pass:), and works, this could be one potential workaround fix.
> >>
> >> Who knows why? The root cause is what?
> >>
> >> I've no idea about this.
> >>
> > I got the same issue while ago. I don't remember exactly everything
> > but my conclusion was that there was some bug in compiler. I think,
> > when 'n' I constant and/or small compiler is inlining memcpy and throwing
> > everything else (including returned value). In that case error is not
> > produced (I think this is a bug in compiler). In other case it is computing
> > some value calling memcpy or rte_ memcpy and you should at least
> > explicitly throw it away by casting to void. I like solution with static
>
> Actually, I try to pass "n" as a Int value like 4, it still report this
> error :)
My workaround was:
(void) rte_memcpy(...);
But this is only a workaround.
>
> > inline but someone else should spoke about possible side effects.
>
> Yes, but as I know inline is better than macros.
>
> Thanks,
> Michael
> >
> > Pawel
> >
> >
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 9:05 [dpdk-dev] error: value computed is not used Qiu, Michael
2014-12-08 11:00 ` Wodkowski, PawelX
@ 2014-12-09 9:19 ` Qiu, Michael
2014-12-10 9:26 ` Qiu, Michael
2 siblings, 0 replies; 18+ messages in thread
From: Qiu, Michael @ 2014-12-09 9:19 UTC (permalink / raw)
To: dev
Any other comments on this issue?
Thanks,
Michael
On 12/8/2014 5:07 PM, Qiu, Michael wrote:
> Hi all,
> My platform is:
>
> uname -a
> Linux suse-11-sp3 3.0.77-0.11-xen #1 SMP Tue Mar 11 16:48:56 CST 2014
> x86_64 x86_64 x86_64 GNU/Linux
>
> gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
> Target: x86_64-suse-linux
> Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
> --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
> --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
> --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5
> --enable-ssp --disable-libssp --disable-plugin
> --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
> --disable-libgcj --disable-libmudflap --with-slibdir=/lib64
> --with-system-zlib --enable-__cxa_atexit
> --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
> --enable-version-specific-runtime-libs --program-suffix=-4.5
> --enable-linux-futex --without-system-libunwind --enable-gold
> --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic
> --build=x86_64-suse-linux
> Thread model: posix
> gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585] (SUSE Linux)
>
> When I try to compile the source code to x86_64 linuxapp, I got this
> error message:
>
> lib/librte_pmd_enic/enic_main.c: In function ‘enic_set_rsskey’:
> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
>
> I dig out that, it was ome issue of the macros rte_memcpy()
> #define rte_memcpy(dst, src, n) \
> ((__builtin_constant_p(n)) ? \
> memcpy((dst), (src), (n)) : \
> rte_memcpy_func((dst), (src), (n)))
>
> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> know that it was incorrect, just a experiment).
>
> But I try to use inline function instead of macros:
> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> {
> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> rte_memcpy_func(dst, src, n);
> }
>
> It will pass:), and works, this could be one potential workaround fix.
>
> Who knows why? The root cause is what?
>
> I've no idea about this.
>
> Thanks,
> Michael
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 9:05 [dpdk-dev] error: value computed is not used Qiu, Michael
2014-12-08 11:00 ` Wodkowski, PawelX
2014-12-09 9:19 ` Qiu, Michael
@ 2014-12-10 9:26 ` Qiu, Michael
2 siblings, 0 replies; 18+ messages in thread
From: Qiu, Michael @ 2014-12-10 9:26 UTC (permalink / raw)
To: dev
Hi all,
Any idea?
Leave this issue in DPDK?
Thanks,
Michael
On 12/8/2014 5:07 PM, Qiu, Michael wrote:
> Hi all,
> My platform is:
>
> uname -a
> Linux suse-11-sp3 3.0.77-0.11-xen #1 SMP Tue Mar 11 16:48:56 CST 2014
> x86_64 x86_64 x86_64 GNU/Linux
>
> gcc -v
> Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
> Target: x86_64-suse-linux
> Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
> --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
> --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
> --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5
> --enable-ssp --disable-libssp --disable-plugin
> --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
> --disable-libgcj --disable-libmudflap --with-slibdir=/lib64
> --with-system-zlib --enable-__cxa_atexit
> --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
> --enable-version-specific-runtime-libs --program-suffix=-4.5
> --enable-linux-futex --without-system-libunwind --enable-gold
> --with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic
> --build=x86_64-suse-linux
> Thread model: posix
> gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585] (SUSE Linux)
>
> When I try to compile the source code to x86_64 linuxapp, I got this
> error message:
>
> lib/librte_pmd_enic/enic_main.c: In function ‘enic_set_rsskey’:
> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
>
> I dig out that, it was ome issue of the macros rte_memcpy()
> #define rte_memcpy(dst, src, n) \
> ((__builtin_constant_p(n)) ? \
> memcpy((dst), (src), (n)) : \
> rte_memcpy_func((dst), (src), (n)))
>
> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> know that it was incorrect, just a experiment).
>
> But I try to use inline function instead of macros:
> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> {
> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> rte_memcpy_func(dst, src, n);
> }
>
> It will pass:), and works, this could be one potential workaround fix.
>
> Who knows why? The root cause is what?
>
> I've no idea about this.
>
> Thanks,
> Michael
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-08 15:26 ` Wodkowski, PawelX
@ 2014-12-15 10:54 ` Thomas Monjalon
2014-12-15 11:07 ` [dpdk-dev] [PATCH] enic: fix build on SUSE 11 Thomas Monjalon
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Thomas Monjalon @ 2014-12-15 10:54 UTC (permalink / raw)
To: Wodkowski, PawelX, Qiu, Michael; +Cc: dev
2014-12-08 15:26, Wodkowski, PawelX:
> From: Qiu, Michael
> > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> > >>
> > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > >> #define rte_memcpy(dst, src, n) \
> > >> ((__builtin_constant_p(n)) ? \
> > >> memcpy((dst), (src), (n)) : \
> > >> rte_memcpy_func((dst), (src), (n)))
> > >>
> > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > >> know that it was incorrect, just a experiment).
> > >>
> > >> But I try to use inline function instead of macros:
> > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > >> {
> > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > >> rte_memcpy_func(dst, src, n);
> > >> }
> > >>
> > >> It will pass:), and works, this could be one potential workaround fix.
> > >>
> > >> Who knows why? The root cause is what?
> > >>
> > >> I've no idea about this.
> > >>
> > > I got the same issue while ago. I don't remember exactly everything
> > > but my conclusion was that there was some bug in compiler. I think,
> > > when 'n' I constant and/or small compiler is inlining memcpy and throwing
> > > everything else (including returned value). In that case error is not
> > > produced (I think this is a bug in compiler). In other case it is computing
> > > some value calling memcpy or rte_ memcpy and you should at least
> > > explicitly throw it away by casting to void. I like solution with static
> >
> > Actually, I try to pass "n" as a Int value like 4, it still report this
> > error :)
>
> My workaround was:
> (void) rte_memcpy(...);
>
> But this is only a workaround.
It's not so bad.
> > > inline but someone else should spoke about possible side effects.
> >
> > Yes, but as I know inline is better than macros.
>From the GCC manual:
"
You may use this built-in function in either a macro or an inline function.
However, if you use it in an inlined function and pass an argument of the
function as the argument to the built-in, GCC never returns 1 when you call
the inline function with a string constant or compound literal and does not
return 1 when you pass a constant numeric value to the inline function unless
you specify the -O option.
"
It seems the "inline fix" cannot be used.
I'm going to send a patch with Pawel's workaround.
--
Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* [dpdk-dev] [PATCH] enic: fix build on SUSE 11
2014-12-15 10:54 ` Thomas Monjalon
@ 2014-12-15 11:07 ` Thomas Monjalon
2014-12-15 11:27 ` [dpdk-dev] error: value computed is not used Wodkowski, PawelX
2014-12-16 0:49 ` Qiu, Michael
2 siblings, 0 replies; 18+ messages in thread
From: Thomas Monjalon @ 2014-12-15 11:07 UTC (permalink / raw)
To: dev
GCC 4.5.1 from SUSE throws this error:
lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
It seems to be a GCC bug.
Reported-by: Michael Qiu <michael.qiu@intel.com>
Suggested-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
lib/librte_pmd_enic/enic_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/librte_pmd_enic/enic_main.c b/lib/librte_pmd_enic/enic_main.c
index e4f43c5..8cfb6e3 100644
--- a/lib/librte_pmd_enic/enic_main.c
+++ b/lib/librte_pmd_enic/enic_main.c
@@ -858,7 +858,8 @@ static int enic_set_rsskey(struct enic *enic)
if (!rss_key_buf_va)
return -ENOMEM;
- rte_memcpy(rss_key_buf_va, &rss_key, sizeof(union vnic_rss_key));
+ /* ignore return to workaround a bug seen with GCC 4.5.1 on SUSE 11 SP3 */
+ (void) rte_memcpy(rss_key_buf_va, &rss_key, sizeof(union vnic_rss_key));
err = enic_set_rss_key(enic,
rss_key_buf_pa,
--
2.1.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 10:54 ` Thomas Monjalon
2014-12-15 11:07 ` [dpdk-dev] [PATCH] enic: fix build on SUSE 11 Thomas Monjalon
@ 2014-12-15 11:27 ` Wodkowski, PawelX
2014-12-15 13:26 ` Thomas Monjalon
2014-12-16 0:49 ` Qiu, Michael
2 siblings, 1 reply; 18+ messages in thread
From: Wodkowski, PawelX @ 2014-12-15 11:27 UTC (permalink / raw)
To: Thomas Monjalon, Qiu, Michael; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, December 15, 2014 11:55 AM
> To: Wodkowski, PawelX; Qiu, Michael
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] error: value computed is not used
>
> 2014-12-08 15:26, Wodkowski, PawelX:
> > From: Qiu, Michael
> > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> > > >>
> > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > >> #define rte_memcpy(dst, src, n) \
> > > >> ((__builtin_constant_p(n)) ? \
> > > >> memcpy((dst), (src), (n)) : \
> > > >> rte_memcpy_func((dst), (src), (n)))
> > > >>
> > > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > > >> know that it was incorrect, just a experiment).
> > > >>
> > > >> But I try to use inline function instead of macros:
> > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > > >> {
> > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > >> rte_memcpy_func(dst, src, n);
> > > >> }
> > > >>
> > > >> It will pass:), and works, this could be one potential workaround fix.
> > > >>
> > > >> Who knows why? The root cause is what?
> > > >>
> > > >> I've no idea about this.
> > > >>
> > > > I got the same issue while ago. I don't remember exactly everything
> > > > but my conclusion was that there was some bug in compiler. I think,
> > > > when 'n' I constant and/or small compiler is inlining memcpy and throwing
> > > > everything else (including returned value). In that case error is not
> > > > produced (I think this is a bug in compiler). In other case it is computing
> > > > some value calling memcpy or rte_ memcpy and you should at least
> > > > explicitly throw it away by casting to void. I like solution with static
> > >
> > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > error :)
> >
> > My workaround was:
> > (void) rte_memcpy(...);
> >
> > But this is only a workaround.
>
> It's not so bad.
>
> > > > inline but someone else should spoke about possible side effects.
> > >
> > > Yes, but as I know inline is better than macros.
>
> From the GCC manual:
> "
> You may use this built-in function in either a macro or an inline function.
> However, if you use it in an inlined function and pass an argument of the
> function as the argument to the built-in, GCC never returns 1 when you call
> the inline function with a string constant or compound literal and does not
> return 1 when you pass a constant numeric value to the inline function unless
> you specify the -O option.
> "
>
> It seems the "inline fix" cannot be used.
>
> I'm going to send a patch with Pawel's workaround.
And something like this?
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..906c911 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h
@@ -168,10 +168,10 @@
rte_mov128(dst + 128, src + 128);
}
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 @@
}
#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)
Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
/home/pwodkowx/grizzly/dpdk_org_declan_v3_mode4_v2/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c: In function 'ixgbe_host_interface_command':
/home/pwodkowx/grizzly/dpdk_org_declan_v3_mode4_v2/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-value]
/home/pwodkowx/grizzly/dpdk_org_declan_v3_mode4_v2/lib/librte_pmd_ixgbe/ixgbe/ixgbe_common.c:4448:3: error: statement with no effect [-Werror=unused-value]
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 11:27 ` [dpdk-dev] error: value computed is not used Wodkowski, PawelX
@ 2014-12-15 13:26 ` Thomas Monjalon
2014-12-15 13:47 ` Wodkowski, PawelX
0 siblings, 1 reply; 18+ messages in thread
From: Thomas Monjalon @ 2014-12-15 13:26 UTC (permalink / raw)
To: Wodkowski, PawelX; +Cc: dev
2014-12-15 11:27, Wodkowski, PawelX:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2014-12-08 15:26, Wodkowski, PawelX:
> > > From: Qiu, Michael
> > > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
> > > > >>
> > > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > > >> #define rte_memcpy(dst, src, n) \
> > > > >> ((__builtin_constant_p(n)) ? \
> > > > >> memcpy((dst), (src), (n)) : \
> > > > >> rte_memcpy_func((dst), (src), (n)))
> > > > >>
> > > > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > > > >> know that it was incorrect, just a experiment).
> > > > >>
> > > > >> But I try to use inline function instead of macros:
> > > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > > > >> {
> > > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > > >> rte_memcpy_func(dst, src, n);
> > > > >> }
> > > > >>
> > > > >> It will pass:), and works, this could be one potential workaround fix.
> > > > >>
> > > > >> Who knows why? The root cause is what?
> > > > >>
> > > > >> I've no idea about this.
> > > > >>
> > > > > I got the same issue while ago. I don't remember exactly everything
> > > > > but my conclusion was that there was some bug in compiler. I think,
> > > > > when 'n' I constant and/or small compiler is inlining memcpy and throwing
> > > > > everything else (including returned value). In that case error is not
> > > > > produced (I think this is a bug in compiler). In other case it is computing
> > > > > some value calling memcpy or rte_ memcpy and you should at least
> > > > > explicitly throw it away by casting to void. I like solution with static
> > > >
> > > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > > error :)
> > >
> > > My workaround was:
> > > (void) rte_memcpy(...);
> > >
> > > But this is only a workaround.
> >
> > It's not so bad.
> >
> > > > > inline but someone else should spoke about possible side effects.
> > > >
> > > > Yes, but as I know inline is better than macros.
> >
> > From the GCC manual:
> > "
> > You may use this built-in function in either a macro or an inline function.
> > However, if you use it in an inlined function and pass an argument of the
> > function as the argument to the built-in, GCC never returns 1 when you call
> > the inline function with a string constant or compound literal and does not
> > return 1 when you pass a constant numeric value to the inline function unless
> > you specify the -O option.
> > "
> >
> > It seems the "inline fix" cannot be used.
> >
> > I'm going to send a patch with Pawel's workaround.
>
> And something like this?
>
> #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)); })
What happens to the returned value after this change?
ptr = rte_memcpy(dst, src, n) + offset:
> Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
You mean EXTRA_CFLAGS (with a S).
It fails in many locations.
What's your point? Do you to support -Wunused-value?
--
Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 13:26 ` Thomas Monjalon
@ 2014-12-15 13:47 ` Wodkowski, PawelX
2014-12-15 14:16 ` Thomas Monjalon
0 siblings, 1 reply; 18+ messages in thread
From: Wodkowski, PawelX @ 2014-12-15 13:47 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, December 15, 2014 2:27 PM
> To: Wodkowski, PawelX
> Cc: Qiu, Michael; dev@dpdk.org
> Subject: Re: [dpdk-dev] error: value computed is not used
>
> 2014-12-15 11:27, Wodkowski, PawelX:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2014-12-08 15:26, Wodkowski, PawelX:
> > > > From: Qiu, Michael
> > > > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not
> used
> > > > > >>
> > > > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > > > >> #define rte_memcpy(dst, src, n) \
> > > > > >> ((__builtin_constant_p(n)) ? \
> > > > > >> memcpy((dst), (src), (n)) : \
> > > > > >> rte_memcpy_func((dst), (src), (n)))
> > > > > >>
> > > > > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > > > > >> know that it was incorrect, just a experiment).
> > > > > >>
> > > > > >> But I try to use inline function instead of macros:
> > > > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > > > > >> {
> > > > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > > > >> rte_memcpy_func(dst, src, n);
> > > > > >> }
> > > > > >>
> > > > > >> It will pass:), and works, this could be one potential workaround fix.
> > > > > >>
> > > > > >> Who knows why? The root cause is what?
> > > > > >>
> > > > > >> I've no idea about this.
> > > > > >>
> > > > > > I got the same issue while ago. I don't remember exactly everything
> > > > > > but my conclusion was that there was some bug in compiler. I think,
> > > > > > when 'n' I constant and/or small compiler is inlining memcpy and
> throwing
> > > > > > everything else (including returned value). In that case error is not
> > > > > > produced (I think this is a bug in compiler). In other case it is computing
> > > > > > some value calling memcpy or rte_ memcpy and you should at least
> > > > > > explicitly throw it away by casting to void. I like solution with static
> > > > >
> > > > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > > > error :)
> > > >
> > > > My workaround was:
> > > > (void) rte_memcpy(...);
> > > >
> > > > But this is only a workaround.
> > >
> > > It's not so bad.
> > >
> > > > > > inline but someone else should spoke about possible side effects.
> > > > >
> > > > > Yes, but as I know inline is better than macros.
> > >
> > > From the GCC manual:
> > > "
> > > You may use this built-in function in either a macro or an inline function.
> > > However, if you use it in an inlined function and pass an argument of the
> > > function as the argument to the built-in, GCC never returns 1 when you call
> > > the inline function with a string constant or compound literal and does not
> > > return 1 when you pass a constant numeric value to the inline function unless
> > > you specify the -O option.
> > > "
> > >
> > > It seems the "inline fix" cannot be used.
> > >
> > > I'm going to send a patch with Pawel's workaround.
> >
> > And something like this?
> >
> > #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)); })
>
> What happens to the returned value after this change?
> ptr = rte_memcpy(dst, src, n) + offset:
>
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
Whole expression should be 'void *' type (like *memcpy()) and it should work
as usual (see maxint() example in above link). It is GCC extension.
> > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
>
> You mean EXTRA_CFLAGS (with a S).
> It fails in many locations.
> What's your point?
I am just asking if this is an typo, error or intend to do statements with no effects like bellow.
ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-value]
4426: /* first pull in the header so we know the buffer length */
4427: for (bi = 0; bi < dword_len; bi++) {
4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
4430 }
> Do you to support -Wunused-value?
No, I just turned this on to check above change and was surprised what happened.
--
Pawel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 13:47 ` Wodkowski, PawelX
@ 2014-12-15 14:16 ` Thomas Monjalon
2014-12-15 15:44 ` Wodkowski, PawelX
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Thomas Monjalon @ 2014-12-15 14:16 UTC (permalink / raw)
To: Wodkowski, PawelX; +Cc: dev
2014-12-15 13:47, Wodkowski, PawelX:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2014-12-15 11:27, Wodkowski, PawelX:
> > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > 2014-12-08 15:26, Wodkowski, PawelX:
> > > > > From: Qiu, Michael
> > > > > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > > > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not
> > used
> > > > > > >>
> > > > > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > > > > >> #define rte_memcpy(dst, src, n) \
> > > > > > >> ((__builtin_constant_p(n)) ? \
> > > > > > >> memcpy((dst), (src), (n)) : \
> > > > > > >> rte_memcpy_func((dst), (src), (n)))
> > > > > > >>
> > > > > > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > > > > > >> know that it was incorrect, just a experiment).
> > > > > > >>
> > > > > > >> But I try to use inline function instead of macros:
> > > > > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > > > > > >> {
> > > > > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > > > > >> rte_memcpy_func(dst, src, n);
> > > > > > >> }
> > > > > > >>
> > > > > > >> It will pass:), and works, this could be one potential workaround fix.
> > > > > > >>
> > > > > > >> Who knows why? The root cause is what?
> > > > > > >>
> > > > > > >> I've no idea about this.
> > > > > > >>
> > > > > > > I got the same issue while ago. I don't remember exactly everything
> > > > > > > but my conclusion was that there was some bug in compiler. I think,
> > > > > > > when 'n' I constant and/or small compiler is inlining memcpy and
> > throwing
> > > > > > > everything else (including returned value). In that case error is not
> > > > > > > produced (I think this is a bug in compiler). In other case it is computing
> > > > > > > some value calling memcpy or rte_ memcpy and you should at least
> > > > > > > explicitly throw it away by casting to void. I like solution with static
> > > > > >
> > > > > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > > > > error :)
> > > > >
> > > > > My workaround was:
> > > > > (void) rte_memcpy(...);
> > > > >
> > > > > But this is only a workaround.
> > > >
> > > > It's not so bad.
> > > >
> > > > > > > inline but someone else should spoke about possible side effects.
> > > > > >
> > > > > > Yes, but as I know inline is better than macros.
> > > >
> > > > From the GCC manual:
> > > > "
> > > > You may use this built-in function in either a macro or an inline function.
> > > > However, if you use it in an inlined function and pass an argument of the
> > > > function as the argument to the built-in, GCC never returns 1 when you call
> > > > the inline function with a string constant or compound literal and does not
> > > > return 1 when you pass a constant numeric value to the inline function unless
> > > > you specify the -O option.
> > > > "
> > > >
> > > > It seems the "inline fix" cannot be used.
> > > >
> > > > I'm going to send a patch with Pawel's workaround.
> > >
> > > And something like this?
> > >
> > > #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)); })
> >
> > What happens to the returned value after this change?
> > ptr = rte_memcpy(dst, src, n) + offset:
> >
> https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
>
> Whole expression should be 'void *' type (like *memcpy()) and it should work
> as usual (see maxint() example in above link). It is GCC extension.
OK nice.
I didn't test it on SUSE 11 SP3. I assume you did it?
Please Pawel, could you send a proper patch quickly?
If nobody disagree, it'll be merged in RC5 today.
> > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> >
> > You mean EXTRA_CFLAGS (with a S).
> > It fails in many locations.
> > What's your point?
>
> I am just asking if this is an typo, error or intend to do statements with no effects like bellow.
>
> ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-value]
>
> 4426: /* first pull in the header so we know the buffer length */
> 4427: for (bi = 0; bi < dword_len; bi++) {
> 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
> 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> 4430 }
It's an intent. On big endian CPU, this has an effect.
> > Do you to support -Wunused-value?
>
> No, I just turned this on to check above change and was surprised what happened.
Honestly, I don't know if there is a good fix for this warning.
--
Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 14:16 ` Thomas Monjalon
@ 2014-12-15 15:44 ` Wodkowski, PawelX
2014-12-15 16:35 ` Ananyev, Konstantin
2014-12-15 16:00 ` Ananyev, Konstantin
2014-12-15 17:03 ` Jastrzebski, MichalX K
2 siblings, 1 reply; 18+ messages in thread
From: Wodkowski, PawelX @ 2014-12-15 15:44 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
> > > > And something like this?
> > > >
> > > > #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)); })
> > >
> > > What happens to the returned value after this change?
> > > ptr = rte_memcpy(dst, src, n) + offset:
> > >
> > https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
> >
> > Whole expression should be 'void *' type (like *memcpy()) and it should work
> > as usual (see maxint() example in above link). It is GCC extension.
>
> OK nice.
> I didn't test it on SUSE 11 SP3. I assume you did it?
I did not tested this, as this was only proposal. I only run build process and it pass.
Patch proposal will be sent in a while.
> Please Pawel, could you send a proper patch quickly?
> If nobody disagree, it'll be merged in RC5 today.
>
> > > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> > >
> > > You mean EXTRA_CFLAGS (with a S).
> > > It fails in many locations.
> > > What's your point?
> >
> > I am just asking if this is an typo, error or intend to do statements with no
> effects like bellow.
> >
> > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-
> value]
> >
> > 4426: /* first pull in the header so we know the buffer length */
> > 4427: for (bi = 0; bi < dword_len; bi++) {
> > 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
> bi);
> > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> > 4430 }
>
> It's an intent. On big endian CPU, this has an effect.
>
If you see something what I am not, please ignore this part but for me this looks like it should be:
tmp = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
buffer[bi] = IXGBE_LE32_TO_CPUS (tmp);
Pawel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 14:16 ` Thomas Monjalon
2014-12-15 15:44 ` Wodkowski, PawelX
@ 2014-12-15 16:00 ` Ananyev, Konstantin
2014-12-15 16:40 ` Thomas Monjalon
2014-12-15 17:03 ` Jastrzebski, MichalX K
2 siblings, 1 reply; 18+ messages in thread
From: Ananyev, Konstantin @ 2014-12-15 16:00 UTC (permalink / raw)
To: Thomas Monjalon, Wodkowski, PawelX; +Cc: dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Monday, December 15, 2014 2:17 PM
> To: Wodkowski, PawelX
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] error: value computed is not used
>
> 2014-12-15 13:47, Wodkowski, PawelX:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2014-12-15 11:27, Wodkowski, PawelX:
> > > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > > 2014-12-08 15:26, Wodkowski, PawelX:
> > > > > > From: Qiu, Michael
> > > > > > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > > > > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > > > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not
> > > used
> > > > > > > >>
> > > > > > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > > > > > >> #define rte_memcpy(dst, src, n) \
> > > > > > > >> ((__builtin_constant_p(n)) ? \
> > > > > > > >> memcpy((dst), (src), (n)) : \
> > > > > > > >> rte_memcpy_func((dst), (src), (n)))
> > > > > > > >>
> > > > > > > >> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
> > > > > > > >> know that it was incorrect, just a experiment).
> > > > > > > >>
> > > > > > > >> But I try to use inline function instead of macros:
> > > > > > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
> > > > > > > >> {
> > > > > > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > > > > > >> rte_memcpy_func(dst, src, n);
> > > > > > > >> }
> > > > > > > >>
> > > > > > > >> It will pass:), and works, this could be one potential workaround fix.
> > > > > > > >>
> > > > > > > >> Who knows why? The root cause is what?
> > > > > > > >>
> > > > > > > >> I've no idea about this.
> > > > > > > >>
> > > > > > > > I got the same issue while ago. I don't remember exactly everything
> > > > > > > > but my conclusion was that there was some bug in compiler. I think,
> > > > > > > > when 'n' I constant and/or small compiler is inlining memcpy and
> > > throwing
> > > > > > > > everything else (including returned value). In that case error is not
> > > > > > > > produced (I think this is a bug in compiler). In other case it is computing
> > > > > > > > some value calling memcpy or rte_ memcpy and you should at least
> > > > > > > > explicitly throw it away by casting to void. I like solution with static
> > > > > > >
> > > > > > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > > > > > error :)
> > > > > >
> > > > > > My workaround was:
> > > > > > (void) rte_memcpy(...);
> > > > > >
> > > > > > But this is only a workaround.
> > > > >
> > > > > It's not so bad.
> > > > >
> > > > > > > > inline but someone else should spoke about possible side effects.
> > > > > > >
> > > > > > > Yes, but as I know inline is better than macros.
> > > > >
> > > > > From the GCC manual:
> > > > > "
> > > > > You may use this built-in function in either a macro or an inline function.
> > > > > However, if you use it in an inlined function and pass an argument of the
> > > > > function as the argument to the built-in, GCC never returns 1 when you call
> > > > > the inline function with a string constant or compound literal and does not
> > > > > return 1 when you pass a constant numeric value to the inline function unless
> > > > > you specify the -O option.
> > > > > "
> > > > >
> > > > > It seems the "inline fix" cannot be used.
> > > > >
> > > > > I'm going to send a patch with Pawel's workaround.
> > > >
> > > > And something like this?
> > > >
> > > > #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)); })
> > >
> > > What happens to the returned value after this change?
> > > ptr = rte_memcpy(dst, src, n) + offset:
> > >
> > https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
> >
> > Whole expression should be 'void *' type (like *memcpy()) and it should work
> > as usual (see maxint() example in above link). It is GCC extension.
>
> OK nice.
> I didn't test it on SUSE 11 SP3. I assume you did it?
> Please Pawel, could you send a proper patch quickly?
> If nobody disagree, it'll be merged in RC5 today.
>
> > > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> > >
> > > You mean EXTRA_CFLAGS (with a S).
> > > It fails in many locations.
> > > What's your point?
> >
> > I am just asking if this is an typo, error or intend to do statements with no effects like bellow.
> >
> > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-value]
> >
> > 4426: /* first pull in the header so we know the buffer length */
> > 4427: for (bi = 0; bi < dword_len; bi++) {
> > 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
> > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> > 4430 }
>
> It's an intent. On big endian CPU, this has an effect.
Hmm, I think there is a bug in lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h:
#define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
It probably should be:
#define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(*(_i))
Not much point to do byte swapping for the pointer.
And that what ixgbe BSD driver is doing.
Though I still not sure why it is needed here, as the computed value is not used anyway.
What the author probably meant to do:
buffer[bi] = rte_le_to_cpu_32 (buffer[bi]);
To achieve that we need:
#define IXGBE_LE32_TO_CPUS(x) (*(x) = rte_le_to_cpu_32(*(x)))
Correct?
Konstantin
>
> > > Do you to support -Wunused-value?
> >
> > No, I just turned this on to check above change and was surprised what happened.
>
> Honestly, I don't know if there is a good fix for this warning.
>
> --
> Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 15:44 ` Wodkowski, PawelX
@ 2014-12-15 16:35 ` Ananyev, Konstantin
0 siblings, 0 replies; 18+ messages in thread
From: Ananyev, Konstantin @ 2014-12-15 16:35 UTC (permalink / raw)
To: Wodkowski, PawelX, Thomas Monjalon; +Cc: dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wodkowski, PawelX
> Sent: Monday, December 15, 2014 3:44 PM
> To: Thomas Monjalon
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] error: value computed is not used
>
> > > > > And something like this?
> > > > >
> > > > > #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)); })
> > > >
> > > > What happens to the returned value after this change?
> > > > ptr = rte_memcpy(dst, src, n) + offset:
> > > >
> > > https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
> > >
> > > Whole expression should be 'void *' type (like *memcpy()) and it should work
> > > as usual (see maxint() example in above link). It is GCC extension.
> >
> > OK nice.
> > I didn't test it on SUSE 11 SP3. I assume you did it?
> I did not tested this, as this was only proposal. I only run build process and it pass.
> Patch proposal will be sent in a while.
>
> > Please Pawel, could you send a proper patch quickly?
> > If nobody disagree, it'll be merged in RC5 today.
> >
> > > > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> > > >
> > > > You mean EXTRA_CFLAGS (with a S).
> > > > It fails in many locations.
> > > > What's your point?
> > >
> > > I am just asking if this is an typo, error or intend to do statements with no
> > effects like bellow.
> > >
> > > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-
> > value]
> > >
> > > 4426: /* first pull in the header so we know the buffer length */
> > > 4427: for (bi = 0; bi < dword_len; bi++) {
> > > 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
> > bi);
> > > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> > > 4430 }
> >
> > It's an intent. On big endian CPU, this has an effect.
> >
>
> If you see something what I am not, please ignore this part but for me this looks like it should be:
> tmp = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
> buffer[bi] = IXGBE_LE32_TO_CPUS (tmp);
Yep, same thought here, see my other mail on that subject.
Konstantin
>
> Pawel
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 16:00 ` Ananyev, Konstantin
@ 2014-12-15 16:40 ` Thomas Monjalon
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Monjalon @ 2014-12-15 16:40 UTC (permalink / raw)
To: Ananyev, Konstantin; +Cc: dev
2014-12-15 16:00, Ananyev, Konstantin:
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> > 2014-12-15 13:47, Wodkowski, PawelX:
> > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > 2014-12-15 11:27, Wodkowski, PawelX:
> > > > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> > > >
> > > > You mean EXTRA_CFLAGS (with a S).
> > > > It fails in many locations.
> > > > What's your point?
> > >
> > > I am just asking if this is an typo, error or intend to do statements with no effects like bellow.
> > >
> > > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-value]
> > >
> > > 4426: /* first pull in the header so we know the buffer length */
> > > 4427: for (bi = 0; bi < dword_len; bi++) {
> > > 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi);
> > > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> > > 4430 }
> >
> > It's an intent. On big endian CPU, this has an effect.
>
> Hmm, I think there is a bug in lib/librte_pmd_ixgbe/ixgbe/ixgbe_osdep.h:
> #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
>
> It probably should be:
> #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(*(_i))
>
> Not much point to do byte swapping for the pointer.
> And that what ixgbe BSD driver is doing.
>
> Though I still not sure why it is needed here, as the computed value is not used anyway.
> What the author probably meant to do:
> buffer[bi] = rte_le_to_cpu_32 (buffer[bi]);
> To achieve that we need:
> #define IXGBE_LE32_TO_CPUS(x) (*(x) = rte_le_to_cpu_32(*(x)))
> Correct?
Oh yes, you and Pawel are probably right.
I was focusing on definition of IXGBE_LE32_TO_CPUS and have not seen the bug.
> > > > Do you to support -Wunused-value?
> > >
> > > No, I just turned this on to check above change and was surprised what happened.
> >
> > Honestly, I don't know if there is a good fix for this warning.
--
Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 14:16 ` Thomas Monjalon
2014-12-15 15:44 ` Wodkowski, PawelX
2014-12-15 16:00 ` Ananyev, Konstantin
@ 2014-12-15 17:03 ` Jastrzebski, MichalX K
2 siblings, 0 replies; 18+ messages in thread
From: Jastrzebski, MichalX K @ 2014-12-15 17:03 UTC (permalink / raw)
To: Thomas Monjalon, Wodkowski, PawelX; +Cc: dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Monday, December 15, 2014 3:17 PM
> To: Wodkowski, PawelX
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] error: value computed is not used
>
> 2014-12-15 13:47, Wodkowski, PawelX:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2014-12-15 11:27, Wodkowski, PawelX:
> > > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > > 2014-12-08 15:26, Wodkowski, PawelX:
> > > > > > From: Qiu, Michael
> > > > > > > On 2014/12/8 19:00, Wodkowski, PawelX wrote:
> > > > > > > >> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
> > > > > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is
> not
> > > used
> > > > > > > >>
> > > > > > > >> I dig out that, it was ome issue of the macros rte_memcpy()
> > > > > > > >> #define rte_memcpy(dst, src, n) \
> > > > > > > >> ((__builtin_constant_p(n)) ? \
> > > > > > > >> memcpy((dst), (src), (n)) : \
> > > > > > > >> rte_memcpy_func((dst), (src), (n)))
> > > > > > > >>
> > > > > > > >> When I use only (n) instead of (__builtin_constant_p(n), it will
> pass( I
> > > > > > > >> know that it was incorrect, just a experiment).
> > > > > > > >>
> > > > > > > >> But I try to use inline function instead of macros:
> > > > > > > >> static inline void * rte_memcpy(void *dst, const void *src, size_t
> n)
> > > > > > > >> {
> > > > > > > >> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
> > > > > > > >> rte_memcpy_func(dst, src, n);
> > > > > > > >> }
> > > > > > > >>
> > > > > > > >> It will pass:), and works, this could be one potential workaround
> fix.
> > > > > > > >>
> > > > > > > >> Who knows why? The root cause is what?
> > > > > > > >>
> > > > > > > >> I've no idea about this.
> > > > > > > >>
> > > > > > > > I got the same issue while ago. I don't remember exactly
> everything
> > > > > > > > but my conclusion was that there was some bug in compiler. I
> think,
> > > > > > > > when 'n' I constant and/or small compiler is inlining memcpy and
> > > throwing
> > > > > > > > everything else (including returned value). In that case error is not
> > > > > > > > produced (I think this is a bug in compiler). In other case it is
> computing
> > > > > > > > some value calling memcpy or rte_ memcpy and you should at
> least
> > > > > > > > explicitly throw it away by casting to void. I like solution with static
> > > > > > >
> > > > > > > Actually, I try to pass "n" as a Int value like 4, it still report this
> > > > > > > error :)
> > > > > >
> > > > > > My workaround was:
> > > > > > (void) rte_memcpy(...);
> > > > > >
> > > > > > But this is only a workaround.
> > > > >
> > > > > It's not so bad.
> > > > >
> > > > > > > > inline but someone else should spoke about possible side effects.
> > > > > > >
> > > > > > > Yes, but as I know inline is better than macros.
> > > > >
> > > > > From the GCC manual:
> > > > > "
> > > > > You may use this built-in function in either a macro or an inline
> function.
> > > > > However, if you use it in an inlined function and pass an argument of
> the
> > > > > function as the argument to the built-in, GCC never returns 1 when you
> call
> > > > > the inline function with a string constant or compound literal and does
> not
> > > > > return 1 when you pass a constant numeric value to the inline function
> unless
> > > > > you specify the -O option.
> > > > > "
> > > > >
> > > > > It seems the "inline fix" cannot be used.
> > > > >
> > > > > I'm going to send a patch with Pawel's workaround.
> > > >
> > > > And something like this?
> > > >
> > > > #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)); })
> > >
> > > What happens to the returned value after this change?
> > > ptr = rte_memcpy(dst, src, n) + offset:
> > >
> > https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs
> >
> > Whole expression should be 'void *' type (like *memcpy()) and it should
> work
> > as usual (see maxint() example in above link). It is GCC extension.
>
> OK nice.
> I didn't test it on SUSE 11 SP3. I assume you did it?
> Please Pawel, could you send a proper patch quickly?
> If nobody disagree, it'll be merged in RC5 today.
Hi Thomas,
I sent this patch on behalf of Pawel. It is:
[PATCH] fix rte_memcpy() macro: avoid unused value warning
Michal
>
> > > > Thomas, can you check build with EXTRA_CFLAG='-Wunused-value'.
> > >
> > > You mean EXTRA_CFLAGS (with a S).
> > > It fails in many locations.
> > > What's your point?
> >
> > I am just asking if this is an typo, error or intend to do statements with no
> effects like bellow.
> >
> > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-
> value]
> >
> > 4426: /* first pull in the header so we know the buffer length */
> > 4427: for (bi = 0; bi < dword_len; bi++) {
> > 4428: buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
> bi);
> > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
> > 4430 }
>
> It's an intent. On big endian CPU, this has an effect.
>
> > > Do you to support -Wunused-value?
> >
> > No, I just turned this on to check above change and was surprised what
> happened.
>
> Honestly, I don't know if there is a good fix for this warning.
>
> --
> Thomas
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [dpdk-dev] error: value computed is not used
2014-12-15 10:54 ` Thomas Monjalon
2014-12-15 11:07 ` [dpdk-dev] [PATCH] enic: fix build on SUSE 11 Thomas Monjalon
2014-12-15 11:27 ` [dpdk-dev] error: value computed is not used Wodkowski, PawelX
@ 2014-12-16 0:49 ` Qiu, Michael
2 siblings, 0 replies; 18+ messages in thread
From: Qiu, Michael @ 2014-12-16 0:49 UTC (permalink / raw)
To: Thomas Monjalon, Wodkowski, PawelX; +Cc: dev
On 12/15/2014 6:55 PM, Thomas Monjalon wrote:
> 2014-12-08 15:26, Wodkowski, PawelX:
>> From: Qiu, Michael
>>> On 2014/12/8 19:00, Wodkowski, PawelX wrote:
>>>>> lib/librte_pmd_enic/enic_main.c: In function 'enic_set_rsskey':
>>>>> lib/librte_pmd_enic/enic_main.c:862:2: error: value computed is not used
>>>>>
>>>>> I dig out that, it was ome issue of the macros rte_memcpy()
>>>>> #define rte_memcpy(dst, src, n) \
>>>>> ((__builtin_constant_p(n)) ? \
>>>>> memcpy((dst), (src), (n)) : \
>>>>> rte_memcpy_func((dst), (src), (n)))
>>>>>
>>>>> When I use only (n) instead of (__builtin_constant_p(n), it will pass( I
>>>>> know that it was incorrect, just a experiment).
>>>>>
>>>>> But I try to use inline function instead of macros:
>>>>> static inline void * rte_memcpy(void *dst, const void *src, size_t n)
>>>>> {
>>>>> return __builtin_constant_p(n) ? memcpy(dst, src, n) :
>>>>> rte_memcpy_func(dst, src, n);
>>>>> }
>>>>>
>>>>> It will pass:), and works, this could be one potential workaround fix.
>>>>>
>>>>> Who knows why? The root cause is what?
>>>>>
>>>>> I've no idea about this.
>>>>>
>>>> I got the same issue while ago. I don't remember exactly everything
>>>> but my conclusion was that there was some bug in compiler. I think,
>>>> when 'n' I constant and/or small compiler is inlining memcpy and throwing
>>>> everything else (including returned value). In that case error is not
>>>> produced (I think this is a bug in compiler). In other case it is computing
>>>> some value calling memcpy or rte_ memcpy and you should at least
>>>> explicitly throw it away by casting to void. I like solution with static
>>> Actually, I try to pass "n" as a Int value like 4, it still report this
>>> error :)
>> My workaround was:
>> (void) rte_memcpy(...);
>>
>> But this is only a workaround.
> It's not so bad.
>
>>>> inline but someone else should spoke about possible side effects.
>>> Yes, but as I know inline is better than macros.
> From the GCC manual:
> "
> You may use this built-in function in either a macro or an inline function.
> However, if you use it in an inlined function and pass an argument of the
> function as the argument to the built-in, GCC never returns 1 when you call
> the inline function with a string constant or compound literal and does not
> return 1 when you pass a constant numeric value to the inline function unless
> you specify the -O option.
> "
>
> It seems the "inline fix" cannot be used.
Actually, it can be used and work, as -O option is always specified(I've
test before).
But it should be a issue and not safe.
Thanks,
Michael
> I'm going to send a patch with Pawel's workaround.
>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2014-12-16 0:50 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 9:05 [dpdk-dev] error: value computed is not used Qiu, Michael
2014-12-08 11:00 ` Wodkowski, PawelX
2014-12-08 15:23 ` Qiu, Michael
2014-12-08 15:26 ` Wodkowski, PawelX
2014-12-15 10:54 ` Thomas Monjalon
2014-12-15 11:07 ` [dpdk-dev] [PATCH] enic: fix build on SUSE 11 Thomas Monjalon
2014-12-15 11:27 ` [dpdk-dev] error: value computed is not used Wodkowski, PawelX
2014-12-15 13:26 ` Thomas Monjalon
2014-12-15 13:47 ` Wodkowski, PawelX
2014-12-15 14:16 ` Thomas Monjalon
2014-12-15 15:44 ` Wodkowski, PawelX
2014-12-15 16:35 ` Ananyev, Konstantin
2014-12-15 16:00 ` Ananyev, Konstantin
2014-12-15 16:40 ` Thomas Monjalon
2014-12-15 17:03 ` Jastrzebski, MichalX K
2014-12-16 0:49 ` Qiu, Michael
2014-12-09 9:19 ` Qiu, Michael
2014-12-10 9:26 ` Qiu, Michael
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).