From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 919B7959 for ; Mon, 15 Dec 2014 17:00:44 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 15 Dec 2014 08:00:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="429178157" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by FMSMGA003.fm.intel.com with ESMTP; 15 Dec 2014 07:49:34 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.144]) by IRSMSX110.ger.corp.intel.com ([169.254.15.55]) with mapi id 14.03.0195.001; Mon, 15 Dec 2014 16:00:34 +0000 From: "Ananyev, Konstantin" To: Thomas Monjalon , "Wodkowski, PawelX" Thread-Topic: [dpdk-dev] error: value computed is not used Thread-Index: AdASxiisLi704rCnRgagZfyMuDIXlQANP/TQAVaWb4AAALwbsAAEld2AAABHqiAAAXW7AAAA4Rvw Date: Mon, 15 Dec 2014 16:00:33 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213C0D6A@IRSMSX105.ger.corp.intel.com> References: <533710CFB86FA344BFBF2D6802E60286C9D989@SHSMSX101.ccr.corp.intel.com> <3427289.cFFhb9tNHS@xps13> <4008093.EPhAooubXd@xps13> In-Reply-To: <4008093.EPhAooubXd@xps13> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] error: value computed is not used X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Dec 2014 16:00:46 -0000 > -----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 >=20 > 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_rss= key': > > > > > > > >> lib/librte_pmd_enic/enic_main.c:862:2: error: value comput= ed 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), i= t 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(d= st, src, n); > > > > > > > >> } > > > > > > > >> > > > > > > > >> It will pass:), and works, this could be one potential wor= karound 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 ev= erything > > > > > > > > but my conclusion was that there was some bug in compiler. = I think, > > > > > > > > when 'n' I constant and/or small compiler is inlining memcp= y and > > > throwing > > > > > > > > everything else (including returned value). In that case er= ror 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 solutio= n with static > > > > > > > > > > > > > > Actually, I try to pass "n" as a Int value like 4, it still r= eport 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 ef= fects. > > > > > > > > > > > > > > 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 argumen= t of the > > > > > function as the argument to the built-in, GCC never returns 1 whe= n you call > > > > > the inline function with a string constant or compound literal an= d does not > > > > > return 1 when you pass a constant numeric value to the inline fun= ction 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 =3D 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. >=20 > 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. >=20 > > > > Thomas, can you check build with EXTRA_CFLAG=3D'-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 w= ith no effects like bellow. > > > > ixgbe_common.c:4429:3: error: statement with no effect [-Werror=3Dunuse= d-value] > > > > 4426: /* first pull in the header so we know the buffer length */ > > 4427: for (bi =3D 0; bi < dword_len; bi++) { > > 4428: buffer[bi] =3D IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); > > 4429: IXGBE_LE32_TO_CPUS(&buffer[bi]); // <------ here > > 4430 } >=20 > 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] =3D rte_le_to_cpu_32 (buffer[bi]); To achieve that we need: #define IXGBE_LE32_TO_CPUS(x) (*(x) =3D rte_le_to_cpu_32(*(x))) Correct? Konstantin >=20 > > > Do you to support -Wunused-value? > > > > No, I just turned this on to check above change and was surprised what = happened. >=20 > Honestly, I don't know if there is a good fix for this warning. >=20 > -- > Thomas