Cast of lvalue warning in the last k 2.6.5-rc2 with last gcc-3.3
Hi all,
here is a warning during the last kernel build (2.6.5-rc2):
gcc -Wp,-MD,arch/parisc/lib/.bitops.o.d -nostdinc -iwithprefix include
-D__KERNEL__ -Iinclude -D__KERNEL__ -Iinclude -Wall -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -pipe -mno-space-regs -mfast-indirect-calls -mdisable-fpregs -ffunction-sections -march=2.0 -mschedule=8000 -O2 -fomit-frame-pointer
-DKBUILD_BASENAME=bitops -DKBUILD_MODNAME=bitops -c -o arch/parisc/lib/bitops.oarch/parisc/lib/bitops.carch/parisc/lib/bitops.c: In function `__xchg32':arch/parisc/lib/bitops.c:40: warning: use of cast expressions as lvalues is deprecatedarch/parisc/lib/bitops.c: In function `__xchg8':arch/parisc/lib/bitops.c:53: warning: use of cast expressions as lvalues is deprecated
And here is a patch proposal:
--- /usr/src/linux-2.6.5-rc2-pa2/arch/parisc/lib/bitops.c.orig 2004-03-22
08:35:45.000000000 +0100
+++ /usr/src/linux-2.6.5-rc2-pa2/arch/parisc/lib/bitops.c 2004-03-22 08:42:10.000000000
+0100
@@ -33,11 +33,10 @@
unsigned long __xchg32(int x, int *ptr)
{
- unsigned long flags;
- unsigned long temp;
+ unsigned long temp, flags;
atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
- (long) temp = (long) *ptr; /* XXX - sign extension wanted? */
+ temp = (unsigned long) *ptr; /* XXX - sign extension wanted? */
*ptr = x; atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); return temp;
@@ -46,11 +45,10 @@
unsigned long __xchg8(char x, char *ptr)
{
- unsigned long flags;
- unsigned long temp;
+ unsigned long temp, flags;
atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
- (long) temp = (long) *ptr; /* XXX - sign extension wanted? */
+ temp = (unsigned long) *ptr; /* XXX - sign extension wanted? */
*ptr = x; atomic_spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); return temp;
@@ -60,8 +58,7 @@
#ifdef __LP64__
unsigned long __cmpxchg_u64(volatile unsigned long *ptr, unsigned long old,
unsigned long new)
{
- unsigned long flags;
- unsigned long prev;
+ unsigned long prev, flags;
atomic_spin_lock_irqsave(ATOMIC_HASH(ptr), flags); if ((prev = *ptr) == old)
==========><=========
What do you thing about?
hth,
Joel
PS1: attached patch in case of bad wrapping webmail
PS2: still have to make the same exercise for:
gcc -Wp,-MD,arch/parisc/lib/.io.o.d -nostdinc -iwithprefix include -D__KERNEL__
-Iinclude -D__KERNEL__ -Iinclude -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -mno-space-regs -mfast-indirect-calls -mdisable-fpregs -ffunction-sections -march=2.0 -mschedule=8000 -O2 -fomit-frame-pointer
-DKBUILD_BASENAME=io -DKBUILD_MODNAME=io -c -o arch/parisc/lib/io.o arch/parisc/lib/io.carch/parisc/lib/io.c: In function `__memcpy_toio':arch/parisc/lib/io.c:24: warning: use of cast expressions as lvalues is deprecated arch/parisc/lib/io.c:24: warning: use of cast expressions as lvalues is deprecated
...
----------------------------------------------------------------------------------------
Tiscali ADSL: 35 €/mois, la meilleure offre du marché!
http://reg.tiscali.be/default.asp?lg=fr
usr/src/linux-2.6.5-rc2-pa2/arch/parisc/lib/bitops.c renamed from usr/src/linux-2.6.5-rc2-pa2/arch/parisc/lib/bitops.c.orig +5 -8
@@ -33,11 +33,10 @@unsigned long __xchg32 (int x,int *ptr) { -unsigned long flags; -unsigned long temp; +unsigned long temp, flags;atomic_spin_lock_irqsave (ATOMIC_HASH (ptr), flags); - (long ) temp = (long ) *ptr;/* XXX - sign extension wanted? */ + temp = (unsigned long ) *ptr;/* XXX - sign extension wanted? */ *ptr = x;atomic_spin_unlock_irqrestore (ATOMIC_HASH (ptr), flags);return temp;
@@ -46,11 +45,10 @@unsigned long __xchg8 (char x,char *ptr) { -unsigned long flags; -unsigned long temp; +unsigned long temp, flags;atomic_spin_lock_irqsave (ATOMIC_HASH (ptr), flags); - (long ) temp = (long ) *ptr;/* XXX - sign extension wanted? */ + temp = (unsigned long ) *ptr;/* XXX - sign extension wanted? */ *ptr = x;atomic_spin_unlock_irqrestore (ATOMIC_HASH (ptr), flags);return temp;
@@ -60,8 +58,7 @@#ifdef __LP64__unsigned long __cmpxchg_u64 (volatile unsigned long *ptr,unsigned long old,unsigned long new) { -unsigned long flags; -unsigned long prev; +unsigned long prev, flags;atomic_spin_lock_irqsave (ATOMIC_HASH (ptr), flags);if ((prev = *ptr) == old)
RE: [parisc-linux] Cast of lvalue warning in the last k 2.6.5-rc2 with last gcc-3.3 (next)
Hi all,
Quoted 7 lines
PS2: still have to make the same exercise for:
gcc -Wp,-MD,arch/parisc/lib/.io.o.d -nostdinc -iwithprefix include >-D__KERNEL__(quoted diff) +0
-3-Iinclude -D__KERNEL__ -Iinclude -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasin -fno-common -pipe -mno-space-regs -mfast-indirect-calls -mdisable-fpregs -ffunction-sections -march=2.0 -mschedule=8000 -O2 >-fomit-frame-pointer -DKBUILD_BASENAME=io -DKBUILD_MODNAME=io -c -o arch/parisc/lib/io.o
Quoted 6 lines
arch/parisc/lib/io.carch/parisc/lib/io.c: In function `__memcpy_toio':arch/parisc/lib/io.c:24: warning: use of cast expressions as lvalues is deprecatedarch/parisc/lib/io.c:24: warning: use of cast expressions as lvalues is deprecated
here is the next io.c diff file proposal (if some interest :) )
parisc/lib/io.c renamed from parisc/lib/io.c.orig +54 -54
@@ -21,19 +21,19 @@ goto bytecopy;while (dest &3 ) {writeb (*(char *)src, dest++); - ((char *)src)++; - count--; + src +=sizeof (char ); + count -=sizeof (char ); }while (count >3 ) {__raw_writel (*(u32 *)src, dest); - src +=4 ; - dest +=4 ; - count -=4 ; + src +=sizeof (u32); + dest +=sizeof (u32); + count -=sizeof (u32); } bytecopy:while (count--) {writeb (*(char *)src, dest++); - ((char *)src)++; + src +=sizeof (char ); } }
@@ -62,39 +62,39 @@/* Then check for misaligned start address */ if (src &1 ) { *(u8 *)dest =readb (src); - ((u8 *)src)++; - ((u8 *)dest)++; - count--; + src +=sizeof (u8); + dest +=sizeof (u8); + count -=sizeof (u8);if (count <2 ) goto bytecopy; }if (src &2 ) { *(u16 *)dest =__raw_readw (src); - ((u16 *)src)++; - ((u16 *)dest)++; - count-=2 ; + src +=sizeof (u16); + dest +=sizeof (u16); + count -=sizeof (u16); }while (count >3 ) { *(u32 *)dest =__raw_readl (src); - dest +=4 ; - src +=4 ; - count -=4 ; + dest +=sizeof (u32); + src +=sizeof (u32); + count -=sizeof (u32); } shortcopy:while (count >1 ) { *(u16 *)dest =__raw_readw (src); - ((u16 *)src)++; - ((u16 *)dest)++; - count-=2 ; + src +=sizeof (u16); + dest +=sizeof (u16); + count -=sizeof (u16); } bytecopy:while (count--) { *(char *)dest =readb (src); - ((char *)src)++; - ((char *)dest)++; + src +=sizeof (char ); + dest +=sizeof (char ); } }
@@ -130,7 +130,7 @@return ; count--; *(unsigned char *) dst =inb (port); - ((unsigned char *) dst)++; + dst +=sizeof (unsigned char ); }while (count >=4 ) {
@@ -141,13 +141,13 @@ w |=inb (port) <<8 ; w |=inb (port); *(unsigned int *) dst = w; - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); }while (count) { --count; *(unsigned char *) dst =inb (port); - ((unsigned char *) dst)++; + dst +=sizeof (unsigned char ); } }
@@ -175,7 +175,7 @@ l =cpu_to_le16 (inw (port)) <<16 ; l |=cpu_to_le16 (inw (port)); *(unsigned int *) dst = l; - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); }if (count) { *(unsigned short *) dst =cpu_to_le16 (inw (port));
@@ -184,15 +184,15 @@case 0x02 :/* Buffer 16-bit aligned */ *(unsigned short *) dst =cpu_to_le16 (inw (port)); - ((unsigned short *) dst)++; - count--; + dst +=sizeof (unsigned short ); + count -=sizeof (unsigned short );while (count>=2 ) { count -=2 ; l =cpu_to_le16 (inw (port)) <<16 ; l |=cpu_to_le16 (inw (port)); *(unsigned int *) dst = l; - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); }if (count) { *(unsigned short *) dst =cpu_to_le16 (inw (port));
@@ -207,12 +207,12 @@ l =cpu_to_le16 (inw (port)); *(unsigned char *) dst = l >>8 ; - ((unsigned char *) dst)++; + dst +=sizeof (unsigned char );while (count--) { l2 =cpu_to_le16 (inw (port)); *(unsigned short *) dst = (l &0xff ) <<8 | (l2 >>8 ); - ((unsigned short *) dst)++; + dst +=sizeof (unsigned short ); l = l2; } *(unsigned char *) dst = l &0xff ;
@@ -241,7 +241,7 @@while (count--) { *(unsigned int *) dst =cpu_to_le32 (inl (port)); - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); }break ;
@@ -250,13 +250,13 @@ l =cpu_to_le32 (inl (port)); *(unsigned short *) dst = l >>16 ; - ((unsigned short *) dst)++; + dst +=sizeof (unsigned short );while (count--) { l2 =cpu_to_le32 (inl (port)); *(unsigned int *) dst = (l &0xffff ) <<16 | (l2 >>16 ); - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); l = l2; } *(unsigned short *) dst = l &0xffff ;
@@ -266,14 +266,14 @@ l =cpu_to_le32 (inl (port)); *(unsigned char *) dst = l >>24 ; - ((unsigned char *) dst)++; + dst +=sizeof (unsigned char ); *(unsigned short *) dst = (l >>8 ) &0xffff ; - ((unsigned short *) dst)++; + dst +=sizeof (unsigned short );while (count--) { l2 =cpu_to_le32 (inl (port)); *(unsigned int *) dst = (l &0xff ) <<24 | (l2 >>8 ); - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); l = l2; } *(unsigned char *) dst = l &0xff ;
@@ -283,16 +283,16 @@ l =cpu_to_le32 (inl (port)); *(unsigned char *) dst = l >>24 ; - ((unsigned char *) dst)++; + dst +=sizeof (unsigned char );while (count--) { l2 =cpu_to_le32 (inl (port)); *(unsigned int *) dst = (l &0xffffff ) <<8 | l2 >>24 ; - ((unsigned int *) dst)++; + dst +=sizeof (unsigned int ); l = l2; } *(unsigned short *) dst = (l >>8 ) &0xffff ; - ((unsigned short *) dst)++; + dst +=sizeof (unsigned short ); *(unsigned char *) dst = l &0xff ;break ; }
@@ -308,9 +308,9 @@void outsb (unsigned long port,const void * src,unsigned long count) {while (count) { - count--;outb (*(char *)src, port); - ((char *) src)++; + src +=sizeof (char ); + count -=sizeof (char ); } }
@@ -333,7 +333,7 @@while (count>=2 ) { count -=2 ; l = *(unsigned int *) src; - ((unsigned int *) src)++; + src +=sizeof (unsigned int );outw (le16_to_cpu (l >>16 ), port);outw (le16_to_cpu (l &0xffff ), port); }
@@ -345,13 +345,13 @@case 0x02 :/* Buffer 16-bit aligned */ outw (le16_to_cpu (*(unsigned short *)src), port); - ((unsigned short *) src)++; + src +=sizeof (unsigned short ); count--;while (count>=2 ) { count -=2 ; l = *(unsigned int *) src; - ((unsigned int *) src)++; + src +=sizeof (unsigned int );outw (le16_to_cpu (l >>16 ), port);outw (le16_to_cpu (l &0xffff ), port); }
@@ -365,13 +365,13 @@* in this case, 16bit will have to do -- DE */ l = *(unsigned char *) src <<8 ; - ((unsigned char *) src)++; + src +=sizeof (unsigned char ); count--;while (count) { count--; l2 = *(unsigned short *) src; - ((unsigned short *) src)++; + src +=sizeof (unsigned short );outw (le16_to_cpu (l | l2 >>8 ), port); l = l2 <<8 ; }
@@ -402,7 +402,7 @@while (count--) {outl (le32_to_cpu (*(unsigned int *) src), port); - ((unsigned int *) src)++; + src +=sizeof (unsigned int ); }break ;
@@ -410,12 +410,12 @@ --count; l = *(unsigned short *) src; - ((unsigned short *) src)++; + src +=sizeof (unsigned short );while (count--) { l2 = *(unsigned int *) src; - ((unsigned int *) src)++; + src +=sizeof (unsigned int );outl (le32_to_cpu (l <<16 | l2 >>16 ), port); l = l2; }
@@ -426,13 +426,13 @@ --count; l = *(unsigned char *) src <<24 ; - ((unsigned char *) src)++; + src +=sizeof (unsigned char ); l |= *(unsigned short *) src <<8 ; - ((unsigned short *) src)++; + src +=sizeof (unsigned short );while (count--) { l2 = *(unsigned int *) src; - ((unsigned int *) src)++; + src +=sizeof (unsigned int );outl (le32_to_cpu (l | l2 >>24 ), port); l = l2 <<8 ; }
@@ -443,16 +443,16 @@ --count; l = *(unsigned char *) src <<24 ; - ((unsigned char *) src)++; + src +=sizeof (unsigned char );while (count--) { l2 = *(unsigned int *) src; - ((unsigned int *) src)++; + src +=sizeof (unsigned int );outl (le32_to_cpu (l | l2 >>8 ), port); l = l2 <<24 ; } l2 = *(unsigned short *) src <<16 ; - ((unsigned short *) src)++; + src +=sizeof (unsigned short ); l2 |= *(unsigned char *) src;outl (le32_to_cpu (l | l2), port);break ;
=========><=========
hth,
Joel
PS: I am runing a kernel with this patch on my n4k :)
----------------------------------------------------------------------------------------
Tiscali ADSL: 35 €/mois, la meilleure offre du marché!
http://reg.tiscali.be/default.asp?lg=fr
parisc/lib/io.c renamed from parisc/lib/io.c.orig +54 -54
306 lines not on this page · raw message
Re: [parisc-linux] Cast of lvalue warning in the last k 2.6.5-rc2 with last gcc-3.3 (next)
parisc/lib/io.c line 25
Quoted 11 lines · Joel Soete
here is the next
io.cdiff file proposal (if some interest :) )parisc/lib/io.c renamed from parisc/lib/io.c.orig +2
-2@@ -21,19 +21,19 @@ goto bytecopy;while (dest &3 ) {writeb (*(char *)src, dest++); - ((char *)src)++; - count--; + src +=sizeof (char ); + count -=sizeof (char );
eww. Here's my attempt at something similar:
@@ -20,8 +20,9 @@ void __memcpy_toio(unsigned long dest, u
if ((dest & 3) != (src & 3))
goto bytecopy;
while (dest & 3) {
- writeb(*(char *)src, dest++);
- ((char *)src)++;
+ writeb(*(char *)src, dest);
+ src++;
+ dest++;
count--;
}
while (count > 3) {parisc/lib/io.c line 31
Quoted 9 lines
parisc/lib/io.c renamed from parisc/lib/io.c.orig +3
-3}while (count >3 ) {__raw_writel (*(u32 *)src, dest); - src +=4 ; - dest +=4 ; - count -=4 ; + src +=sizeof (u32); + dest +=sizeof (u32); + count -=sizeof (u32);
No, don't change these.
Quoted 5 lines
parisc/lib/io.c renamed from parisc/lib/io.c.orig +1
-1bytecopy:while (count--) {writeb (*(char *)src, dest++); - ((char *)src)++; + src +=sizeof (char );
...
- writeb(*(char *)src, dest++); - ((char *)src)++; + writeb(*(char *)src, dest); + src++; + dest++;
...
I don't have time to finish off this patch right now. Want to take a stab at redoing it?
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain
Re: [parisc-linux] Cast of lvalue warning in the last k 2.6.5-rc2 with last gcc-3.3 (next)
Quoted 12 lines
parisc/lib/io.c line 31
Quoted 10 lines
parisc/lib/io.c renamed from parisc/lib/io.c.orig +3
-3}while (count >3 ) {__raw_writel (*(u32 *)src, dest); - src +=4 ; - dest +=4 ; - count -=4 ; + src +=sizeof (u32); + dest +=sizeof (u32); + count -=sizeof (u32);No, don't change these.
Just to explain that it was inspired by a Andreas Jaeger's patch (http://sources.redhat.com/ml/libc-hacker/2004-03/msg00007.html)
and wasn't originaly requested by the warning.
But I find it nice to add it to show the relationship between __raw_writel()
and increment, decrement actions.
That said, there are no urgency to fix it: it is still a warning with gcc-3.3 :)
Thanks for feedback,
Joel
T
----------------------------------------------------------------------------------------
Tiscali ADSL: 35 €/mois, la meilleure offre du marché!
http://reg.tiscali.be/default.asp?lg=fr