Skip to contentSkip to conversation

error: value computed is not used

PATCH New Qiu, Michael 5 participants 18 messages Dec 8, 2014 – Dec 16, 2014 7 messages not in the archive

lore
Share & tools
lore
#0 lore raw

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

A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286C9D989-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org

#2 lore raw
Quoted 19 lines

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);
}

Quoted 6 lines

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

#3 lore raw
Quoted 25 lines · PawelX
Quoted 19 lines

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);
}

Quoted 6 lines

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.

Quoted 7 lines

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 :)

Quoted 1 line

inline but someone else should spoke about possible side effects.

Yes, but as I know inline is better than macros.

Thanks,
Michael

Quoted 4 lines

Pawel

A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286C9DB8B-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org

#5 lore raw
Quoted 42 lines

-----Original Message-----
From: Qiu, Michael
Sent: Monday, December 08, 2014 4:24 PM
To: Wodkowski, PawelX; [email protected]
Subject: Re: error: value computed is not used

Quoted 25 lines · PawelX
Quoted 19 lines

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);
}

Quoted 6 lines

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.

Quoted 7 lines

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

Quoted 2 lines

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.

Quoted 11 lines
Quoted 2 lines

inline but someone else should spoke about possible side effects.

Yes, but as I know inline is better than macros.

Thanks,
Michael

Quoted 4 lines

Pawel

A message that is not in the archive (sent off-list or not yet received): F6F2A6264E145F47A18AB6DF8E87425D12B67782-kPTMFJFq+rFP9JyJpTNKArfspsVTdybXVpNB7YpNyf8@public.gmane.org

#7 lore raw

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 35 lines

From: Qiu, Michael

Quoted 34 lines · PawelX
Quoted 32 lines
Quoted 19 lines

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);
}

Quoted 6 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 1 line
Thomas
#8 lore raw

PATCH 1/1 enic: fix build on SUSE 11

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.

---
 lib/librte_pmd_enic/enic_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/librte_pmd_enic/enic_main.c +2 -1
index e4f43c5..8cfb6e3 100644
@@ -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,
Signature · 1 line
2.1.3
#9 lore raw
In reply to Thomas Monjalon
Quoted 68 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, December 15, 2014 11:55 AM
To: Wodkowski, PawelX; Qiu, Michael
Cc: [email protected]
Subject: Re: [dpdk-dev] error: value computed is not used

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 35 lines

From: Qiu, Michael

Quoted 34 lines · PawelX
Quoted 32 lines
Quoted 19 lines

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);
}

Quoted 6 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.
"

Quoted 3 lines

It seems the "inline fix" cannot be used.

I'm going to send a patch with Pawel's workaround.

And something like this?

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +0 -0
index 290c5cd..906c911 100644
@@ -168,10 +168,10 @@
 	rte_mov128(dst + 128, src + 128);
 }
 
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
index 290c5cd..c3e8b81 100644
@@ -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]

A message that is not in the archive (sent off-list or not yet received): F6F2A6264E145F47A18AB6DF8E87425D12B79ECF-kPTMFJFq+rFP9JyJpTNKArfspsVTdybXVpNB7YpNyf8@public.gmane.org

#11 lore raw

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 68 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 60 lines

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 35 lines

From: Qiu, Michael

Quoted 34 lines · PawelX
Quoted 32 lines
Quoted 19 lines

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);
}

Quoted 6 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.
"

Quoted 3 lines

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) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 5 lines
lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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:

Quoted 1 line

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?

Signature · 1 line
Thomas
#12 lore raw
Quoted 79 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, December 15, 2014 2:27 PM
To: Wodkowski, PawelX
Cc: Qiu, Michael; [email protected]
Subject: Re: [dpdk-dev] error: value computed is not used

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 6 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 4 lines

From: Qiu, Michael

Quoted 3 lines · PawelX
Quoted 2 lines
Quoted 2 lines

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

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

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

Quoted 35 lines
Quoted 29 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.
"

Quoted 3 lines

It seems the "inline fix" cannot be used.

I'm going to send a patch with Pawel's workaround.

And something like this?

Quoted 10 lines

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 6 lines

#define rte_memcpy(dst, src, n) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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.

Quoted 5 lines
Quoted 1 line

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 }

Quoted 1 line

Do you to support -Wunused-value?

No, I just turned this on to check above change and was surprised what happened.

Signature · 1 line
Pawel

A message that is not in the archive (sent off-list or not yet received): F6F2A6264E145F47A18AB6DF8E87425D12B79F59-kPTMFJFq+rFP9JyJpTNKArfspsVTdybXVpNB7YpNyf8@public.gmane.org

#14 lore raw

2014-12-15 13:47, Wodkowski, PawelX:

Quoted 81 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 70 lines

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 6 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 4 lines

From: Qiu, Michael

Quoted 3 lines · PawelX
Quoted 2 lines
Quoted 2 lines

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

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

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

Quoted 35 lines
Quoted 29 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.
"

Quoted 3 lines

It seems the "inline fix" cannot be used.

I'm going to send a patch with Pawel's workaround.

And something like this?

Quoted 10 lines

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 6 lines

#define rte_memcpy(dst, src, n) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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:

Quoted 4 lines

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.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 7 lines

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.

Quoted 3 lines
Quoted 1 line

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.

Signature · 1 line
Thomas
#15 lore raw
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 8 lines

And something like this?

#define rte_memcpy(dst, src, n) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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:

Quoted 7 lines
Quoted 4 lines

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.

Quoted 15 lines

Please Pawel, could you send a proper patch quickly? If nobody disagree, it'll be merged in RC5 today.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 2 lines

ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-

value]

Quoted 1 line
Quoted 9 lines
Quoted 3 lines

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);

Quoted 2 lines

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

A message that is not in the archive (sent off-list or not yet received): F6F2A6264E145F47A18AB6DF8E87425D12B79FC6-kPTMFJFq+rFP9JyJpTNKArfspsVTdybXVpNB7YpNyf8@public.gmane.org

#17 lore raw
Quoted 53 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Wodkowski, PawelX
Sent: Monday, December 15, 2014 3:44 PM
To: Thomas Monjalon
Cc: [email protected]
Subject: Re: [dpdk-dev] error: value computed is not used

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Review

Quoted 8 lines

And something like this?

#define rte_memcpy(dst, src, n) \

(quoted diff) +2 -2
-	((__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:

Quoted 7 lines
Quoted 4 lines

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.

Quoted 22 lines

Please Pawel, could you send a proper patch quickly? If nobody disagree, it'll be merged in RC5 today.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

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.

Quoted 2 lines

ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-

value]

Quoted 4 lines

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);

Quoted 2 lines

4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
4430 }

Quoted 6 lines
Quoted 2 lines

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

Quoted 2 lines

Pawel

#18 lore raw
In reply to Thomas Monjalon
Quoted 111 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, December 15, 2014 2:17 PM
To: Wodkowski, PawelX
Cc: [email protected]
Subject: Re: [dpdk-dev] error: value computed is not used

2014-12-15 13:47, Wodkowski, PawelX:

Quoted 81 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 70 lines

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 6 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 4 lines

From: Qiu, Michael

Quoted 3 lines · PawelX
Quoted 2 lines
Quoted 2 lines

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

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

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

Quoted 35 lines
Quoted 29 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

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

Quoted 7 lines
Quoted 2 lines

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.

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.
"

Quoted 3 lines

It seems the "inline fix" cannot be used.

I'm going to send a patch with Pawel's workaround.

And something like this?

Quoted 10 lines

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 6 lines

#define rte_memcpy(dst, src, n) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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:

Quoted 4 lines

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.

Quoted 10 lines
Quoted 5 lines
Quoted 1 line

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]

Quoted 7 lines
Quoted 5 lines

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

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

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

A message that is not in the archive (sent off-list or not yet received): 2601191342CEEE43887BDE71AB977258213C0D6A-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org

#20 lore raw

2014-12-15 16:00, Ananyev, Konstantin:

Quoted 31 lines

From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon

Quoted 13 lines

2014-12-15 13:47, Wodkowski, PawelX:

Quoted 12 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 6 lines

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 1 line

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]

Quoted 7 lines
Quoted 5 lines

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.

Quoted 6 lines

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.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 1 line
Thomas
#21 lore raw
In reply to Thomas Monjalon
Quoted 104 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, December 15, 2014 3:17 PM
To: Wodkowski, PawelX
Cc: [email protected]
Subject: Re: [dpdk-dev] error: value computed is not used

2014-12-15 13:47, Wodkowski, PawelX:

Quoted 8 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 7 lines

2014-12-15 11:27, Wodkowski, PawelX:

Quoted 6 lines

From: Thomas Monjalon [mailto:[email protected]]

Quoted 5 lines

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 4 lines

From: Qiu, Michael

Quoted 3 lines · PawelX
Quoted 2 lines
Quoted 2 lines

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

Quoted 9 lines
Quoted 9 lines

used

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

{
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.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

but my conclusion was that there was some bug in compiler. I

think,

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

when 'n' I constant and/or small compiler is inlining memcpy and

throwing

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

some value calling memcpy or rte_ memcpy and you should at

least

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

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.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

However, if you use it in an inlined function and pass an argument of

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

function as the argument to the built-in, GCC never returns 1 when you

call

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the inline function with a string constant or compound literal and does

not

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

return 1 when you pass a constant numeric value to the inline function

unless

Quoted 21 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

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?

Quoted 10 lines

lib/librte_eal/common/include/arch/x86/rte_memcpy.h line 174

Quoted 6 lines

#define rte_memcpy(dst, src, n) \

lib/librte_eal/common/include/arch/x86/rte_memcpy.h +2 -2
-	((__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

Quoted 8 lines
Quoted 1 line

Whole expression should be 'void *' type (like *memcpy()) and it should

work

Quoted 1 line

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

Quoted 31 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

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.

Quoted 2 lines

ixgbe_common.c:4429:3: error: statement with no effect [-Werror=unused-

value]

Quoted 4 lines

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);

Quoted 2 lines

4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here
4430 }

It's an intent. On big endian CPU, this has an effect.

Quoted 3 lines
Quoted 1 line

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

#22 lore raw
In reply to Thomas Monjalon
Quoted 55 lines · Thomas Monjalon

2014-12-08 15:26, Wodkowski, PawelX:

Quoted 34 lines

From: Qiu, Michael

Quoted 33 lines · PawelX
Quoted 32 lines
Quoted 19 lines

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);
}

Quoted 6 lines

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

Quoted 6 lines
Quoted 2 lines

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.

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

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.
"

Quoted 1 line

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

Quoted 2 lines

I'm going to send a patch with Pawel's workaround.

#23 lore raw
In reply to Qiu, Michael

Any other comments on this issue?

Thanks,
Michael

Quoted 59 lines · Michael

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

#24 lore raw
In reply to Qiu, Michael

Hi all,

Any idea?

Leave this issue in DPDK?

Thanks,
Michael

Quoted 59 lines · Michael

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