PATCH: fix some 32bit isms
Fairly self explanatory. int is not size_t.
Alan
OSDL Developer Certificate of Origin 1.0 included herein by reference
drivers/message/fusion/mptbase.c +1 -1
@@ -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 ; }
drivers/mtd/inftlmount.c +8 -6
@@ -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);
Followup to: <[email protected]> By author: Alan Cox <[email protected]> In newsgroup: linux.dev.kernel
Quoted 13 lines
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/excludelinux.vanilla-2.6.8-rc2/drivers/message/fusion/mptbase.clinux-2.6.8-rc2/drivers/message/fusion/mptbase.c
drivers/message/fusion/mptbase.c line 2423
Quoted 8 lines
drivers/message/fusion/mptbase.c +1
-1@@ -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
Quoted 1 line · On Wed, 28 Jul 2004 09:59:41 -0400 Alan Cox <[email protected]> wrote:
Fairly self explanatory. int is not
size_t.
And size_t is not "%ld" either.
Review
Quoted 2 lines
(quoted diff) +1
-1- "failed (%d bytes)\n", + "failed (%ld bytes)\n",
Rather, it is either "%Zd" or "%zd". Please fix :-)
Quoted 5 lines · Alan Cox
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
Quoted 6 lines
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.
Quoted 8 lines · Andrew Morton
Quoted 5 lines · Alan Cox
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
Quoted 2 lines
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
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernel
Quoted 10 lines
Quoted 5 lines · Alan Cox
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
Quoted 11 lines · H. Peter Anvin
Followup to: <[email protected]> By author: Andrew Morton <[email protected]> In newsgroup: linux.dev.kernelQuoted 8 lines
Quoted 5 lines · Alan Cox
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,
Quoted 6 lines
Quoted 2 lines
printk expects %zd for a
size_tIt should be %zu, since
size_tis 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()...
Quoted 6 lines · On Sat, Aug 07, 2004 at 12:03:05AM +0100…
Quoted 3 lines
It should be %zu, since
size_tis 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 withptrdiff_there.
*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 ;-)
Quoted 1 line
BTW, we ought to add 't' modifier in
vsnpritf()...