* PATCH: fix some 32bit isms
@ 2004-07-28 13:59 Alan Cox
2004-07-28 15:42 ` H. Peter Anvin
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Alan Cox @ 2004-07-28 13:59 UTC (permalink / raw)
To: akpm, linux-kernel
Fairly self explanatory. int is not size_t.
Alan
OSDL Developer Certificate of Origin 1.0 included herein by reference
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.8-rc2/drivers/message/fusion/mptbase.c linux-2.6.8-rc2/drivers/message/fusion/mptbase.c
--- linux.vanilla-2.6.8-rc2/drivers/message/fusion/mptbase.c 2004-07-27 19:22:42.000000000 +0100
+++ linux-2.6.8-rc2/drivers/message/fusion/mptbase.c 2004-07-28 14:27:53.603586584 +0100
@@ -2417,7 +2417,7 @@
} else {
printk(MYIOC_s_ERR_FMT
"Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
- ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
+ ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
RequestFrameSize)/sizeof(u32)));
return -66;
}
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.8-rc2/drivers/mtd/inftlmount.c linux-2.6.8-rc2/drivers/mtd/inftlmount.c
--- linux.vanilla-2.6.8-rc2/drivers/mtd/inftlmount.c 2004-07-27 19:22:43.000000000 +0100
+++ linux-2.6.8-rc2/drivers/mtd/inftlmount.c 2004-07-28 14:31:37.711517000 +0100
@@ -58,7 +58,7 @@
u8 buf[SECTORSIZE];
struct INFTLMediaHeader *mh = &inftl->MediaHdr;
struct INFTLPartition *ip;
- int retlen;
+ size_t retlen;
DEBUG(MTD_DEBUG_LEVEL3, "INFTL: find_boot_record(inftl=0x%x)\n",
(int)inftl);
@@ -288,7 +288,7 @@
inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
if (!inftl->PUtable) {
printk(KERN_WARNING "INFTL: allocation of PUtable "
- "failed (%d bytes)\n",
+ "failed (%ld bytes)\n",
inftl->nb_blocks * sizeof(u16));
return -ENOMEM;
}
@@ -297,7 +297,7 @@
if (!inftl->VUtable) {
kfree(inftl->PUtable);
printk(KERN_WARNING "INFTL: allocation of VUtable "
- "failed (%d bytes)\n",
+ "failed (%ld bytes)\n",
inftl->nb_blocks * sizeof(u16));
return -ENOMEM;
}
@@ -348,7 +348,8 @@
static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
int len, int check_oob)
{
- int i, retlen;
+ int i;
+ size_t retlen;
u8 buf[SECTORSIZE + inftl->mbd.mtd->oobsize];
DEBUG(MTD_DEBUG_LEVEL3, "INFTL: check_free_sectors(inftl=0x%x,"
@@ -382,7 +383,7 @@
*/
int INFTL_formatblock(struct INFTLrecord *inftl, int block)
{
- int retlen;
+ size_t retlen;
struct inftl_unittail uci;
struct erase_info *instr = &inftl->instr;
int physblock;
@@ -551,7 +552,8 @@
int chain_length, do_format_chain;
struct inftl_unithead1 h0;
struct inftl_unittail h1;
- int i, retlen;
+ int i;
+ size_t retlen;
u8 *ANACtable, ANAC;
DEBUG(MTD_DEBUG_LEVEL3, "INFTL: INFTL_mount(inftl=0x%x)\n", (int)s);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-07-28 13:59 PATCH: fix some 32bit isms Alan Cox
@ 2004-07-28 15:42 ` H. Peter Anvin
2004-07-28 15:51 ` David S. Miller
2004-07-28 16:23 ` Andrew Morton
2 siblings, 0 replies; 8+ messages in thread
From: H. Peter Anvin @ 2004-07-28 15:42 UTC (permalink / raw)
To: linux-kernel
Followup to: <20040728135941.GA17409@devserv.devel.redhat.com>
By author: Alan Cox <alan@redhat.com>
In newsgroup: linux.dev.kernel
>
> Fairly self explanatory. int is not size_t.
>
> Alan
>
> OSDL Developer Certificate of Origin 1.0 included herein by reference
>
>
> diff -u --new-file --recursive --exclude-from /usr/src/exclude
> linux.vanilla-2.6.8-rc2/drivers/message/fusion/mptbase.c linux-2.6.8-rc2/drivers/message/fusion/mptbase.c
> --- linux.vanilla-2.6.8-rc2/drivers/message/fusion/mptbase.c 2004-07-27 19:22:42.000000000 +0100
> +++ linux-2.6.8-rc2/drivers/message/fusion/mptbase.c 2004-07-28 14:27:53.603586584 +0100
> @@ -2417,7 +2417,7 @@
> } else {
> printk(MYIOC_s_ERR_FMT
> "Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
> - ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
> + ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
> RequestFrameSize)/sizeof(u32)));
> return -66;
> }
This is probably better fixed by changing %d to %zu.
-hpa
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-07-28 13:59 PATCH: fix some 32bit isms Alan Cox
2004-07-28 15:42 ` H. Peter Anvin
@ 2004-07-28 15:51 ` David S. Miller
2004-07-28 16:23 ` Andrew Morton
2 siblings, 0 replies; 8+ messages in thread
From: David S. Miller @ 2004-07-28 15:51 UTC (permalink / raw)
To: Alan Cox; +Cc: akpm, linux-kernel
On Wed, 28 Jul 2004 09:59:41 -0400
Alan Cox <alan@redhat.com> wrote:
> Fairly self explanatory. int is not size_t.
And size_t is not "%ld" either.
> - "failed (%d bytes)\n",
> + "failed (%ld bytes)\n",
Rather, it is either "%Zd" or "%zd". Please fix :-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-07-28 13:59 PATCH: fix some 32bit isms Alan Cox
2004-07-28 15:42 ` H. Peter Anvin
2004-07-28 15:51 ` David S. Miller
@ 2004-07-28 16:23 ` Andrew Morton
2004-07-28 16:27 ` Alan Cox
2004-08-06 22:53 ` H. Peter Anvin
2 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2004-07-28 16:23 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
Alan Cox <alan@redhat.com> wrote:
>
> printk(MYIOC_s_ERR_FMT
> "Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
> - ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
> + ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
printk expects %zd for a size_t
> RequestFrameSize)/sizeof(u32)));
> ...
> printk(KERN_WARNING "INFTL: allocation of PUtable "
> - "failed (%d bytes)\n",
> + "failed (%ld bytes)\n",
> inftl->nb_blocks * sizeof(u16));
Some architectures will emit a warning here, and will perhaps print the
wrong thing. We need to print size_t's with %zd. I'll fix that up.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-07-28 16:23 ` Andrew Morton
@ 2004-07-28 16:27 ` Alan Cox
2004-08-06 22:53 ` H. Peter Anvin
1 sibling, 0 replies; 8+ messages in thread
From: Alan Cox @ 2004-07-28 16:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: Alan Cox, linux-kernel
On Wed, Jul 28, 2004 at 09:23:34AM -0700, Andrew Morton wrote:
> Alan Cox <alan@redhat.com> wrote:
> >
> > printk(MYIOC_s_ERR_FMT
> > "Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
> > - ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
> > + ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
>
> printk expects %zd for a size_t
So I've now learned. I've been a bit out of touch with the 2.5/2.6 printk
evolution
> Some architectures will emit a warning here, and will perhaps print the
> wrong thing. We need to print size_t's with %zd. I'll fix that up.
Thanks
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-07-28 16:23 ` Andrew Morton
2004-07-28 16:27 ` Alan Cox
@ 2004-08-06 22:53 ` H. Peter Anvin
2004-08-06 23:03 ` viro
1 sibling, 1 reply; 8+ messages in thread
From: H. Peter Anvin @ 2004-08-06 22:53 UTC (permalink / raw)
To: linux-kernel
Followup to: <20040728092334.74e0cfcd.akpm@osdl.org>
By author: Andrew Morton <akpm@osdl.org>
In newsgroup: linux.dev.kernel
>
> Alan Cox <alan@redhat.com> wrote:
> >
> > printk(MYIOC_s_ERR_FMT
> > "Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
> > - ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
> > + ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
>
> printk expects %zd for a size_t
>
It should be %zu, since size_t is unsigned.
%zd is appropriate for ssize_t.
-hpa
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-08-06 22:53 ` H. Peter Anvin
@ 2004-08-06 23:03 ` viro
2004-08-06 23:07 ` viro
0 siblings, 1 reply; 8+ messages in thread
From: viro @ 2004-08-06 23:03 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux-kernel
On Fri, Aug 06, 2004 at 10:53:50PM +0000, H. Peter Anvin wrote:
> Followup to: <20040728092334.74e0cfcd.akpm@osdl.org>
> By author: Andrew Morton <akpm@osdl.org>
> In newsgroup: linux.dev.kernel
> >
> > Alan Cox <alan@redhat.com> wrote:
> > >
> > > printk(MYIOC_s_ERR_FMT
> > > "Invalid IOC facts reply, msgLength=%d offsetof=%d!\n",
> > > - ioc->name, facts->MsgLength, (offsetof(IOCFactsReply_t,
> > > + ioc->name, facts->MsgLength, (int)(offsetof(IOCFactsReply_t,
> >
> > printk expects %zd for a size_t
> >
>
> It should be %zu, since size_t is unsigned.
>
> %zd is appropriate for ssize_t.
It's signed (and not a ssize_t, while we are at it). If you want to be
pedantic, use %td since we are dealing with ptrdiff_t here.
BTW, we ought to add 't' modifier in vsnpritf()...
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: PATCH: fix some 32bit isms
2004-08-06 23:03 ` viro
@ 2004-08-06 23:07 ` viro
0 siblings, 0 replies; 8+ messages in thread
From: viro @ 2004-08-06 23:07 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux-kernel
On Sat, Aug 07, 2004 at 12:03:05AM +0100, viro@parcelfarce.linux.theplanet.co.uk wrote:
> > It should be %zu, since size_t is unsigned.
> >
> > %zd is appropriate for ssize_t.
>
> It's signed (and not a ssize_t, while we are at it). If you want to be
> pedantic, use %td since we are dealing with ptrdiff_t here.
*Ugh*
We are not doing homegrown offsetof(), so it's really size_t. My apologies.
Yes, that should be> %zu (OTOH, %zd will do the same unless we have 2Gb
struct somewhere ;-)
> BTW, we ought to add 't' modifier in vsnpritf()...
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-08-06 23:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-28 13:59 PATCH: fix some 32bit isms Alan Cox
2004-07-28 15:42 ` H. Peter Anvin
2004-07-28 15:51 ` David S. Miller
2004-07-28 16:23 ` Andrew Morton
2004-07-28 16:27 ` Alan Cox
2004-08-06 22:53 ` H. Peter Anvin
2004-08-06 23:03 ` viro
2004-08-06 23:07 ` viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox