From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755324AbcECGhw (ORCPT ); Tue, 3 May 2016 02:37:52 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:58744 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773AbcECGhu convert rfc822-to-8bit (ORCPT ); Tue, 3 May 2016 02:37:50 -0400 From: Arnd Bergmann To: Andrew Morton Cc: mm-commits@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, jpoimboe@redhat.com, Martin Jambor , "Martin K. Petersen" , James Bottomley , Denys Vlasenko , Thomas Graf , Peter Zijlstra , David Rientjes , Ingo Molnar , Himanshu Madhani , Dept-Eng QLA2xxx Upstream , Jan Hubicka Subject: Re: [PATCH v2] byteswap: try to avoid __builtin_constant_p gcc bug Date: Tue, 03 May 2016 08:36:53 +0200 Message-ID: <12243652.bxSxEgjgfk@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160502163225.8b00a5ef7170a0f2533438e9@linux-foundation.org> References: <1780465.XdtPJpi8Tt@wuerfel> <2346484.tQ1Ts8bYKc@wuerfel> <20160502163225.8b00a5ef7170a0f2533438e9@linux-foundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="utf-8" X-Provags-ID: V03:K0:18yrV/JFvEV3WU8/EGPbDFQf4JL0horL7kMM4imHVXQ/VhG0fKu WlHdPIoM4taIOzXxkSI3laBbarvWtchvmONullbJdeWr5bFdKEFgRppQ21w5Y9gQJZraCwj gI+Vzr66S6M9Y1TcG9bhuP9vjl5kOtrINEQV6Kf/2uQUfcy7qW3u+B3RWkmCq4O8PqKZGi9 /q1x/bVoBn0QErWbGZNWQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:ygKU+g+7g3M=:om249MFqSaJ50MLx1XWCY+ aT+DtvwKAUb8xKagz8WFq+Rf6iRPmBXRj1VMgjk69KET83y6L/oxgnvk0mQLJDZ5XFruDavPT +1+0cd6C7+CcZWteOflJJzLjIGLOLO33r0X0xTjAfLX19+azHIFRgOKDKNm1wdxlHo6k66t1u G58donDn9OjUHIrNFpzHAO+ti2U7ztJPwbhnNOYvt4kLvxm33Gx2qYDfmmMEbXHSvrDzi8TiV kxFBvJwBqRX+dVm3Q+5PsSCgaWygYzdeL5/BEaBEveM4i4qM74j2akxeKtqhHs5p/AfWDjzan vIV0bImhFGhgOGl2XMgykqwz+xTYwUHYke73jP6a39+INvh68U3rvtAjhhN2LOPtEUABeQuOk 2yAxClnlR24CamepIfEa81vffihf8YMOJVLpENh9py/xvFgzW5ZVW1dBSI1GSSRvIQgGlwb+7 TZrabZR7p/UAogbveEevLL2CQ9UPDBmOB3AzNKj/6xt98fP1D5QPR6v4ExZDtPewP/G96Yd3H 0Sa1k3lbul5zkLnqJDsilHgP3dshZdxcDx4PTBgzGmXSPa6KK6hh46av1raV7N8BaSlUnT5Dt CRX5mOgtj+tH1pCqiMlghZVWVHbbl/7ADFZJXW8YtY7PCqNQGniC6o988uojfoTyBrvyuHGF0 aNUUzC+a66YLO3SNkMlsa8sLXxjAb1h/HIcg+d2MTGjEZYS5uey7Nkk/Deh46rOhYKxrc1YL8 Jv8bZo8I1FC/nXHo Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 02 May 2016 16:32:25 Andrew Morton wrote: > On Tue, 03 May 2016 01:10:16 +0200 Arnd Bergmann wrote: > > > On Monday 02 May 2016 16:02:18 Andrew Morton wrote: > > > On Mon, 02 May 2016 23:48:19 +0200 Arnd Bergmann wrote: > > > > > > > This is another attempt to avoid a regression in wwn_to_u64() after > > > > that started using get_unaligned_be64(), which in turn ran into a > > > > bug on gcc-4.9 through 6.1. > > > > > > I'm still getting a couple screenfuls of things like > > > > > > net/tipc/name_distr.c: In function 'tipc_named_process_backlog': > > > net/tipc/name_distr.c:330: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'unsigned int' > > > net/tipc/name_distr.c:330: warning: format '%u' expects type 'unsigned int', but argument 4 has type 'unsigned int' > > > net/tipc/name_distr.c:330: warning: format '%u' expects type 'unsigned int', but argument 5 has type 'unsigned int' > > > net/tipc/name_distr.c:330: warning: format '%u' expects type 'unsigned int', but argument 7 has type 'unsigned int' > > > > I've built a few thousand kernels (arm32 with gcc-6.1) with the patch applied, > > but didn't see this one. What target architecture and compiler version produced > > this? Does it go away if you add a (__u32) cast? I don't even know what the > > warning is trying to tell me. > > heh, I didn't actually read it. > > Hopefully we can write this off as a gcc-4.4.4 glitch. 4.8.4 is OK. Ah, old compiler. I've tried gcc-4.3 now on ARM, and I don't get this warning (just a lot "may be used uninitialized"), but unlike gcc-4.4, my version doesn't actually get into the code path I have changed because __builtin_bswap32 was only introduced with 4.4. I don't have gcc-4.4 and 4.5 here, but the warning does show up with 4.6, 4.7 and 4.8: drivers/soc/sunxi/sunxi_sram.c: In function ‘sunxi_sram_show’: drivers/soc/sunxi/sunxi_sram.c:103:7: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=] 4.8 is probably still common enough that we should try to address this. This change addresses the problem for me with ARM gcc-4.8, but adding two more type casts. This also makes the 16/32/64 bit swaps all look the same. I would expect this to also have the same effect on 4.4. Please fold into the previous patch. Signed-off-by: Arnd Bergmann diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h index d737804af181..8f3a8f606fd9 100644 --- a/include/uapi/linux/swab.h +++ b/include/uapi/linux/swab.h @@ -97,7 +97,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) * @x: value to byteswap */ #ifdef __HAVE_BUILTIN_BSWAP16__ -#define __swab16(x) __builtin_bswap16((__u16)(x)) +#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x)) #else #define __swab16(x) \ (__builtin_constant_p((__u16)(x)) ? \ @@ -110,7 +110,7 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) * @x: value to byteswap */ #ifdef __HAVE_BUILTIN_BSWAP32__ -#define __swab32(x) __builtin_bswap32((__u32)(x)) +#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) #else #define __swab32(x) \ (__builtin_constant_p((__u32)(x)) ? \