Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1511438

Re: [PATCH] lpfc: use %zd format string for size_t

Path csiph.com!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Vineet Gupta <Vineet.Gupta1@synopsys.com>
Newsgroups linux.kernel
Subject Re: [PATCH] lpfc: use %zd format string for size_t
Date Fri, 28 Oct 2016 23:50:01 +0200
Message-ID <sxncd-5pM-7@gated-at.bofh.it> (permalink)
References <stfmV-3uj-15@gated-at.bofh.it> <sxmzw-59w-17@gated-at.bofh.it> <sxn2x-5mx-7@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0
MIME-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding 8bit
X-Originating-IP [10.10.161.37]
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 57
Organization linux.* mail to news gateway
X-Original-Cc arcml <linux-snps-arc@lists.infradead.org>, lkml <linux-kernel@vger.kernel.org>, Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com>
X-Original-Date Fri, 28 Oct 2016 14:44:13 -0700
X-Original-Message-ID <27a8ca4b-3259-17bd-acbf-ee809ec4f67b@synopsys.com>
X-Original-Newsgroups gmane.linux.kernel.arc,gmane.linux.kernel
X-Original-References <20161017123605.2217411-1-arnd@arndb.de> <26e675e3-af5b-eaf7-fea0-b4aff9767332@synopsys.com> <18294392.WY3416IpNg@wuerfel>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1511438

Show key headers only | View raw


On 10/28/2016 02:33 PM, Arnd Bergmann wrote:
> On Friday, October 28, 2016 2:03:21 PM CEST Vineet Gupta wrote:
>>
>> I'm trying to use about to be released ARC gcc 6.x with current kernels and see a
>> flood of warnings due to these legit fixes - i.e.g arc gcc 6.2 complains when it
>> sees -zx formats.
>>
>> CC      mm/percpu.o
>> ../mm/percpu.c: In function ‘pcpu_alloc’:
>> ../mm/percpu.c:890:14: warning: format ‘%zu’ expects argument of type ‘size_t’,
>> but argument 4 has type ‘unsigned int’ [-Wformat=]
>>    WARN(true, "illegal size (%zu) or align (%zu) for percpu allocation\n",
>>
>> I'm not sure what is going on since the data type is size_t alright - although
>> from posix_types.h is
>>
>> typedef unsigned int __kernel_size_t;
>> typedef __kernel_size_t size_t;
>>
>> And this seems to be same for ARC as well as ARM. I tried ARM gcc 6.1 @
>> https://snapshots.linaro.org/components/toolchain/binaries/6.1-2016.08-rc1/arm-linux-gnueabihf/
>>
>> which doesn't seem to be complaining.
>>
>> With V=1, I checked the respective ARM and ARC toggles in play, but nothing
>> related to this seems to be standing out.
>>
>> I know this is more of a question to our GNU folks, but was wondering if you had
>> more insight into it - which you almost always do 
> 
> I've seen the problem you describe before, but I don't remember the
> exact details. I think what happened is that the compiler knows
> what type size_t is supposed to be, either unsigned int or unsigned
> long, regardless of what our kernel headers say it is.
> 
> This is configuration specific, and something caused your compiler to
> be built assuming that size_t is unsigned long, while the kernel
> headers are assuming it should be unsigned int.
> 
> You can try overriding __kernel_size_t in your asm/posix_types.h
> to define it as unsigned long, 


Indeed if I hack include/linux/types.h

-typedef __kernel_size_t                size_t;
+typedef unsigned long          size_t;

then the warning goes away, so gcc is indeed assuming size_t to be unsigned long
and not unsigned int. That helps a lot.

or try to build your compiler
> to match the kernel headers, but the first step would be to find
> out why the compiler changed in the first place, assuming that older
> compiler versions were matching the kernel here.
> 
> 	Arnd

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] lpfc: use %zd format string for size_t Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-10-28 23:10 +0200
  Re: [PATCH] lpfc: use %zd format string for size_t Arnd Bergmann <arnd@arndb.de> - 2016-10-28 23:40 +0200
    Re: [PATCH] lpfc: use %zd format string for size_t Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-10-28 23:50 +0200
      Re: [PATCH] lpfc: use %zd format string for size_t Arnd Bergmann <arnd@arndb.de> - 2016-10-29 00:00 +0200
      Re: [PATCH] lpfc: use %zd format string for size_t Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-10-29 00:00 +0200
        Re: [PATCH] lpfc: use %zd format string for size_t Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-10-29 00:00 +0200
          Re: [PATCH] lpfc: use %zd format string for size_t Arnd Bergmann <arnd@arndb.de> - 2016-10-29 00:10 +0200
            Re: [PATCH] lpfc: use %zd format string for size_t Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-10-29 01:30 +0200

csiph-web