DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wodkowski, PawelX" <pawelx.wodkowski@intel.com>
To: Thomas Monjalon <thomas.monjalon@6wind.com>,
	"Qiu, Michael" <michael.qiu@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] error: value computed is not used
Date: Mon, 15 Dec 2014 11:27:35 +0000	[thread overview]
Message-ID: <F6F2A6264E145F47A18AB6DF8E87425D12B79ECF@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <19703944.gAxOdpYSXo@xps13>


> -----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]

  parent reply	other threads:[~2014-12-15 11:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-08  9:05 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         ` Wodkowski, PawelX [this message]
2014-12-15 13:26           ` [dpdk-dev] error: value computed is not used 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F6F2A6264E145F47A18AB6DF8E87425D12B79ECF@IRSMSX102.ger.corp.intel.com \
    --to=pawelx.wodkowski@intel.com \
    --cc=dev@dpdk.org \
    --cc=michael.qiu@intel.com \
    --cc=thomas.monjalon@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).