Skip to contentSkip to conversation

Some cleanup patches for: '...lvalues is deprecated'

PATCH Joel Soete 6 participants 14 messages Jul 3, 2004 – Jul 30, 2004

Subsystems (4)
lore
Share & tools
lore

Joel Soete

author
#0 lore raw

Hi Marcelo,

Please appolgies first for wrong presentation of previous post (that was the first and certainly the last time that I used the 'forwarding' option of this webmail interface :( ).

Here are some backport to clean up some warning of type: use of cast experssion as lvalues is deprecated.

kernel/sysctl.c renamed from kernel/sysctl.c.Orig +3 -3
@@ -890,7 +890,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;
@@ -1043,7 +1043,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;
@@ -1144,7 +1144,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;

=========><=========

fs/readdir.c renamed from fs/readdir.c.Orig +2 -2
@@ -264,7 +264,7 @@
 	put_user(reclen, &dirent->d_reclen);
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (void *)dirent + reclen;
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
@@ -347,7 +347,7 @@
 	copy_to_user(dirent, &d, NAME_OFFSET(&d));
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (void *)dirent + reclen;
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;

=========><=========

drivers/video/fbcon.c renamed from drivers/video/fbcon.c.Orig +4 -1
@@ -1877,7 +1877,10 @@
        font length must be multiple of 256, at least. And 256 is multiple
        of 4 */
     k = 0;
-    while (p > new_data) k += *--(u32 *)p;
+    while (p > new_data) {
+        p = (u8 *)((u32 *)p - 1);
+        k += *(u32 *)p;
+    }
     FNTSUM(new_data) = k;
     /* Check if the same font is on some other console already */
     for (i = 0; i < MAX_NR_CONSOLES; i++) {

=========><=========

lib/crc32.c renamed from lib/crc32.c.Orig +12 -4
@@ -99,7 +99,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -120,7 +122,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while (--len);
 	}
 
@@ -200,7 +204,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -221,7 +227,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while (--len);
 	}
 	return __be32_to_cpu(crc);

=========><=========

hth,
Joel

PS: because of bad wrapping pb with mail interface I also join original files

lib/crc32.c renamed from lib/crc32.c.Orig +12 -4
@@ -99,7 +99,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -120,7 +122,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while (--len);
 	}
 
@@ -200,7 +204,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -221,7 +227,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *p = (u8 *)b;
+			DO_CRC(*p++);
+			b = (void *)p;
 		} while (--len);
 	}
 	return __be32_to_cpu(crc);
drivers/video/fbcon.c renamed from drivers/video/fbcon.c.Orig +4 -1
@@ -1877,7 +1877,10 @@
        font length must be multiple of 256, at least. And 256 is multiple
        of 4 */
     k = 0;
-    while (p > new_data) k += *--(u32 *)p;
+    while (p > new_data) {
+        p = (u8 *)((u32 *)p - 1);
+        k += *(u32 *)p;
+    }
     FNTSUM(new_data) = k;
     /* Check if the same font is on some other console already */
     for (i = 0; i < MAX_NR_CONSOLES; i++) {
fs/readdir.c renamed from fs/readdir.c.Orig +2 -2
@@ -264,7 +264,7 @@
 	put_user(reclen, &dirent->d_reclen);
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (void *)dirent + reclen;
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
@@ -347,7 +347,7 @@
 	copy_to_user(dirent, &d, NAME_OFFSET(&d));
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (void *)dirent + reclen;
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
kernel/sysctl.c renamed from kernel/sysctl.c.Orig +3 -3
@@ -890,7 +890,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;
@@ -1043,7 +1043,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;
@@ -1144,7 +1144,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);
 			}
 			if (!left)
 				break;
#1 lore raw
Quoted 14 lines · Joel Soete

Hi Marcelo,

Please appolgies first for wrong presentation of previous post (that was the first and certainly the last time that I used the 'forwarding' option of this webmail interface :( ).

Here are some backport to clean up some warning of type: use of cast experssion
as lvalues is deprecated.
--- linux-2.4.27-rc2-pa4mm/kernel/sysctl.c.Orig 2004-06-29
09:03:42.000000000 +0200
+++ linux-2.4.27-rc2-pa4mm/kernel/sysctl.c 2004-06-29
10:10:31.588030256 +0200

kernel/sysctl.c line 893

Quoted 5 lines
kernel/sysctl.c renamed from kernel/sysctl.c.Orig +1 -1
@@ -890,7 +890,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);

This (although correct in the end) is a wrong thing to do.

It seems to look like the intention is to move the pointer by a char's size, however your change is equivalent to:

	buffer += 1;

And if buffer wasn't void*, which it fortunately is, it would, unlike the older construction, move the pointer by a different size.

So just use

	buffer++;

here, and the intent is then clear.

drivers/video/fbcon.c line 1883

Quoted 13 lines
(quoted diff) +0 -1
--- linux-2.4.27-rc2-pa4mm/drivers/video/fbcon.c.Orig	2004-06-29 

10:47:31.901491304 +0200
+++ linux-2.4.27-rc2-pa4mm/drivers/video/fbcon.c 2004-06-29
11:13:31.846343640 +0200

drivers/video/fbcon.c renamed from drivers/video/fbcon.c.Orig +4 -1
@@ -1877,7 +1877,10 @@
        font length must be multiple of 256, at least. And 256 is multiple
        of 4 */
     k = 0;
-    while (p > new_data) k += *--(u32 *)p;
+    while (p > new_data) {
+        p = (u8 *)((u32 *)p - 1);
+        k += *(u32 *)p;
+    }

How about

	p -= 4;
	k += *(u32 *)p;
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
author
#2 lore raw

Thanks first for your attention ;)

Quoted 22 lines · Vojtech Pavlik
Quoted 11 lines · Joel Soete

Hi Marcelo,

Please appolgies first for wrong presentation of previous post (that was the first and certainly the last time that I used the 'forwarding' option of this webmail interface :( ).

Here are some backport to clean up some warning of type: use of cast experssion as lvalues is deprecated.
--- linux-2.4.27-rc2-pa4mm/kernel/sysctl.c.Orig 2004-06-29
09:03:42.000000000 +0200
+++ linux-2.4.27-rc2-pa4mm/kernel/sysctl.c 2004-06-29
10:10:31.588030256 +0200

kernel/sysctl.c line 893

Quoted 5 lines
kernel/sysctl.c renamed from kernel/sysctl.c.Orig +1 -1
@@ -890,7 +890,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);

This (although correct in the end) is a wrong thing to do.

Quoted 8 lines

It seems to look like the intention is to move the pointer by a char's size, however your change is equivalent to:

	buffer += 1;

And if buffer wasn't void*, which it fortunately is, it would, unlike the older construction, move the pointer by a different size.

Very interesting but well I am not enough fluent in C to understand this fine detail :(
Can you explain me by an example (let say a long*) what would did "((char *) buffer)++;" versus "buffer += sizeof(char);" (Don't worry, if don't have time, I will perfectly understand and will experiment by myself)

Quoted 6 lines

So just use

	buffer++;

here, and the intent is then clear.

Yes ;)

Quoted 19 lines
Quoted 6 lines
(quoted diff) +0 -1
--- linux-2.4.27-rc2-pa4mm/drivers/video/fbcon.c.Orig	2004-06-29 

10:47:31.901491304 +0200
+++ linux-2.4.27-rc2-pa4mm/drivers/video/fbcon.c 2004-06-29
11:13:31.846343640 +0200

drivers/video/fbcon.c line 1883

Quoted 8 lines
drivers/video/fbcon.c renamed from drivers/video/fbcon.c.Orig +4 -1
@@ -1877,7 +1877,10 @@
       font length must be multiple of 256, at least. And 256 is multiple
       of 4 */
    k = 0;
-    while (p > new_data) k += *--(u32 *)p;
+    while (p > new_data) {
+        p = (u8 *)((u32 *)p - 1);
+        k += *(u32 *)p;
+    }

How about

Quoted 3 lines
	p -= 4;
	k += *(u32 *)p;

:)

Thanks again,
Joel

#3 lore raw
Quoted 6 lines · Joel Soete

Very interesting but well I am not enough fluent in C to understand this fine detail :(
Can you explain me by an example (let say a long*) what would did "((char *) buffer)++;" versus "buffer += sizeof(char);"
(Don't worry, if don't have time, I will perfectly understand and will experiment by myself)

Ok. Let's assume

	int *buffer;

just for this example.

	((char *) buffer)++;

increments buffer by 1, while

	buffer += sizeof(char);

increments buffer by 4, because an int* is always
increased/decreased by multiples of sizeof(int).

So

	buffer += 2;

would increment the pointer by 8.

Similarly for other pointer types.

Quoted 7 lines
Quoted 6 lines

So just use

	buffer++;

here, and the intent is then clear.

Yes ;)

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#4 lore raw
In reply to Vojtech Pavlik
Quoted 28 lines · Vojtech Pavlik
Quoted 14 lines · Joel Soete

Hi Marcelo,

Please appolgies first for wrong presentation of previous post (that was the first and certainly the last time that I used the 'forwarding' option of this webmail interface :( ).

Here are some backport to clean up some warning of type: use of cast experssion
as lvalues is deprecated.
--- linux-2.4.27-rc2-pa4mm/kernel/sysctl.c.Orig 2004-06-29
09:03:42.000000000 +0200
+++ linux-2.4.27-rc2-pa4mm/kernel/sysctl.c 2004-06-29
10:10:31.588030256 +0200

kernel/sysctl.c line 893

Quoted 5 lines
kernel/sysctl.c renamed from kernel/sysctl.c.Orig +1 -1
@@ -890,7 +890,7 @@
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				buffer += sizeof(char);

This (although correct in the end) is a wrong thing to do.

It seems to look like the intention is to move the pointer by a char's size, however your change is equivalent to:

	buffer += 1;
Quoted 8 lines

And if buffer wasn't void*, which it fortunately is, it would, unlike the older construction, move the pointer by a different size.

So just use

	buffer++;

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size. You can't do arithmetic on one either. GNU C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Signature · 1 line
Daniel Jacobowitz
#5 lore raw
Quoted 4 lines · Daniel Jacobowitz

Except C does not actually allow incrementing a void pointer, since void does not have a size. You can't do arithmetic on one either. GNU C allows this as an extension.

GCC seems to have a whole bunch of ill thought out extensions like this.

David Vrabel

Signature · 4 lines
David Vrabel, Design Engineer

Arcom, Clifton Road           Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK         Web: http://www.arcom.com/
author
#6 lore raw
In reply to Daniel Jacobowitz

Hello Daniel,

Quoted 8 lines
Quoted 5 lines

So just use

	buffer++;

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size.

That make better sense to me because aifair a void * was foreseen to pass any kind of type * as actual parameter?
(So as far as I understand, the aritthm pointer sould be dynamic for the best 'natural' behaviour?)

Quoted 6 lines

You can't do arithmetic on one either. GNU
C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Many thanks,
Joel

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr

#7 lore raw
Quoted 6 lines · Joel Soete

Hello Daniel,

Quoted 4 lines
Quoted 4 lines

So just use

	buffer++;
Quoted 14 lines
Quoted 4 lines
Quoted 1 line

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size.

That make better sense to me because aifair a void * was foreseen to pass any kind of type * as actual parameter?
(So as far as I understand, the aritthm pointer sould be dynamic for the best 'natural' behaviour?)

Quoted 5 lines

You can't do arithmetic on one either. GNU
C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Joel,

It seems the current code is working perfectly, generating correct asm code.

Could you come up with a good enough reason to do this cleanup (as far as I am concerned) in 2.4.x series?

Thanks

author
#8 lore raw

Marcelo,

Thanks first for your attention.
Sorry also for delaying this works but I was a bit busy elsewhere.

Quoted 10 lines

-- Original Message --
Date: Tue, 27 Jul 2004 09:54:32 -0300
From: Marcelo Tosatti <[email protected]>
To: Joel Soete <[email protected]>
Cc: Daniel Jacobowitz <[email protected]>,
Vojtech Pavlik <[email protected]>,
Linux Kernel <[email protected]>
Subject: Re: Some cleanup patches for: '...lvalues is deprecated'

Quoted 13 lines
Quoted 12 lines · Joel Soete

Hello Daniel,

Quoted 9 lines
Quoted 5 lines

So just use

	buffer++;

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size.

That make better sense to me because aifair a void * was foreseen to

pass

Quoted 2 lines
Quoted 2 lines

any kind of type * as actual parameter?
(So as far as I understand, the aritthm pointer sould be dynamic for

the

Quoted 8 lines
Quoted 7 lines

best 'natural' behaviour?)

Quoted 5 lines

You can't do arithmetic on one either. GNU
C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Quoted 6 lines

Joel,

It seems the current code is working perfectly, generating correct asm code.

Could you come up with a good enough reason to do this cleanup (as far

as

Quoted 3 lines

I am concerned) in 2.4.x series?

My first attention was to cleanup some warning of type "use of cast expression as lvalue is deprecated"
with gcc-3.3.4. But afaik, right now, there are just few warning which didn't break the asm code.

I will try to come back asap with a better solution (at least I hope ;) )

Thanks again,
Joel

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr

#9 lore raw
Quoted 46 lines · Joel Soete

Marcelo,

Thanks first for your attention.
Sorry also for delaying this works but I was a bit busy elsewhere.

Quoted 10 lines

-- Original Message --
Date: Tue, 27 Jul 2004 09:54:32 -0300
From: Marcelo Tosatti <[email protected]>
To: Joel Soete <[email protected]>
Cc: Daniel Jacobowitz <[email protected]>,
Vojtech Pavlik <[email protected]>,
Linux Kernel <[email protected]>
Subject: Re: Some cleanup patches for: '...lvalues is deprecated'

Quoted 13 lines
Quoted 12 lines · Joel Soete

Hello Daniel,

Quoted 9 lines
Quoted 5 lines

So just use

	buffer++;

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size.

That make better sense to me because aifair a void * was foreseen to

pass

Quoted 2 lines
Quoted 2 lines

any kind of type * as actual parameter?
(So as far as I understand, the aritthm pointer sould be dynamic for

the

Quoted 8 lines
Quoted 7 lines

best 'natural' behaviour?)

Quoted 5 lines

You can't do arithmetic on one either. GNU
C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Quoted 6 lines

Joel,

It seems the current code is working perfectly, generating correct asm code.

Could you come up with a good enough reason to do this cleanup (as far

Quoted 8 lines

as

Quoted 3 lines

I am concerned) in 2.4.x series?

My first attention was to cleanup some warning of type "use of cast expression as lvalue is deprecated"
with gcc-3.3.4. But afaik, right now, there are just few warning which didn't break the asm code.

FYI, lvalue casts are treated as errors in gcc 3.5.

Regards,
Jon Oberheide

Signature · 3 lines
Jon Oberheide <[email protected]>
GnuPG Key: 1024D/F47C17FE
Fingerprint: B716 DA66 8173 6EDD 28F6  F184 5842 1C89 F47C 17FE
author
#10 lore raw

Hello *,

Quoted 3 lines

FYI, lvalue casts are treated as errors in gcc 3.5.

According to this kind remark, I think so that following attachement patches would be interesting.
Thanks for all relevant remarks to help me to make stuff cleaner.

Joel

PS: I don't yet review the lib/crc32.c (sorry I need more effort to review)

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr

drivers/video/fbcon.c renamed from drivers/video/fbcon.c.Orig +4 -1
@@ -1877,7 +1877,10 @@
        font length must be multiple of 256, at least. And 256 is multiple
        of 4 */
     k = 0;
-    while (p > new_data) k += *--(u32 *)p;
+    while (p > new_data) {
+	p -= 4;
+	k += *(u32 *)p;
+    }
     FNTSUM(new_data) = k;
     /* Check if the same font is on some other console already */
     for (i = 0; i < MAX_NR_CONSOLES; i++) {
fs/readdir.c renamed from fs/readdir.c.Orig +2 -2
@@ -264,7 +264,7 @@
 	put_user(reclen, &dirent->d_reclen);
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (struct linux_dirent *)((char *)dirent + reclen);
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
@@ -347,7 +347,7 @@
 	copy_to_user(dirent, &d, NAME_OFFSET(&d));
 	copy_to_user(dirent->d_name, name, namlen);
 	put_user(0, dirent->d_name + namlen);
-	((char *) dirent) += reclen;
+	dirent = (struct linux_dirent64 *)((char *)dirent + reclen);
 	buf->current_dir = dirent;
 	buf->count -= reclen;
 	return 0;
kernel/sysctl.c renamed from kernel/sysctl.c.Orig +9 -6
@@ -883,14 +883,15 @@
 	
 	for (; left && vleft--; i++, first=0) {
 		if (write) {
+			p = buffer;
 			while (left) {
 				char c;
-				if (get_user(c, (char *) buffer))
+				if (get_user(c, p))
 					return -EFAULT;
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				p++;
 			}
 			if (!left)
 				break;
@@ -1036,14 +1037,15 @@
 	
 	for (; left && vleft--; i++, min++, max++, first=0) {
 		if (write) {
+			p = buffer;
 			while (left) {
 				char c;
-				if (get_user(c, (char *) buffer))
+				if (get_user(c, p))
 					return -EFAULT;
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				p++;
 			}
 			if (!left)
 				break;
@@ -1137,14 +1139,15 @@
 	
 	for (; left && vleft--; i++, first=0) {
 		if (write) {
+			p = (char *)buffer;
 			while (left) {
 				char c;
-				if (get_user(c, (char *) buffer))
+				if (get_user(c, p))
 					return -EFAULT;
 				if (!isspace(c))
 					break;
 				left--;
-				((char *) buffer)++;
+				p++;
 			}
 			if (!left)
 				break;
author
#11 lore raw

Sorry but previous time included file were well readable and not this time? too bad.

So here there are (cut and past? sorry in advance if bad wrapping will occurs)

--- linux-2.4.27-rc3-pa6mm/kernel/sysctl.c.Orig 2004-06-29 09:03:42.000000000
+0200
+++ linux-2.4.27-rc3-pa6mm/kernel/sysctl.c 2004-07-29 11:41:30.021094824
+0200
@@ -883,14 +883,15 @@

for (; left && vleft--; i++, first=0) {
if (write) {
+ p = buffer;
while (left) {
char c;
- if (get_user(c, (char *) buffer))
+ if (get_user(c, p))
return -EFAULT;
if (!isspace(c))
break;
left--;
- ((char *) buffer)++;
+ p++;
}
if (!left)
break;
@@ -1036,14 +1037,15 @@

for (; left && vleft--; i++, min++, max++, first=0) {
if (write) {
+ p = buffer;
while (left) {
char c;
- if (get_user(c, (char *) buffer))
+ if (get_user(c, p))
return -EFAULT;
if (!isspace(c))
break;
left--;
- ((char *) buffer)++;
+ p++;
}
if (!left)
break;
@@ -1137,14 +1139,15 @@

for (; left && vleft--; i++, first=0) {
if (write) {
+ p = (char *)buffer;
while (left) {
char c;
- if (get_user(c, (char *) buffer))
+ if (get_user(c, p))
return -EFAULT;
if (!isspace(c))
break;
left--;
- ((char *) buffer)++;
+ p++;
}
if (!left)
break;
--- linux-2.4.27-rc3-pa6mm/fs/readdir.c.Orig 2004-06-29 11:18:46.000000000
+0200
+++ linux-2.4.27-rc3-pa6mm/fs/readdir.c 2004-07-29 12:54:45.000000000 +0200
@@ -264,7 +264,7 @@
put_user(reclen, &dirent->d_reclen); copy_to_user(dirent->d_name, name, namlen); put_user(0, dirent->d_name + namlen);
- ((char *) dirent) += reclen;
+ dirent = (struct linux_dirent *)((char *)dirent + reclen);
buf->current_dir = dirent;
buf->count -= reclen;
return 0;
@@ -347,7 +347,7 @@
copy_to_user(dirent, &d, NAME_OFFSET(&d)); copy_to_user(dirent->d_name, name, namlen); put_user(0, dirent->d_name + namlen);
- ((char *) dirent) += reclen;
+ dirent = (struct linux_dirent64 *)((char *)dirent + reclen);
buf->current_dir = dirent;
buf->count -= reclen;
return 0;
--- linux-2.4.27-rc3-pa6mm/drivers/video/fbcon.c.Orig 2004-06-29 10:47:31.000000000
+0200
+++ linux-2.4.27-rc3-pa6mm/drivers/video/fbcon.c 2004-07-30 09:21:43.295828520
+0200
@@ -1877,7 +1877,10 @@

        font length must be multiple of 256, at least. And 256 is multiple
        of 4 */
     k = 0;

- while (p > new_data) k += *--(u32 *)p;
+ while (p > new_data) {
+ p -= 4;
+ k += *(u32 *)p;
+ }

     FNTSUM(new_data) = k;
     /* Check if the same font is on some other console already */
     for (i = 0; i < MAX_NR_CONSOLES; i++) {

=========><=========

Quoted 20 lines

-- Original Message --
Date: Fri, 30 Jul 2004 11:11:32 +0200
From: "Joel Soete" <[email protected]>
Subject: Re: Some cleanup patches for: '...lvalues is deprecated'
To: "Jon Oberheide" <[email protected]>
Cc: "Marcelo Tosatti" <[email protected]>,
"Daniel Jacobowitz" <[email protected]>,
"Vojtech Pavlik" <[email protected]>,
"Linux Kernel" <[email protected]>

Hello *,

Quoted 3 lines

FYI, lvalue casts are treated as errors in gcc 3.5.

According to this kind remark, I think so that following attachement patches would be interesting.
Thanks for all relevant remarks to help me to make stuff cleaner.

Quoted 7 lines

Joel

PS: I don't yet review the lib/crc32.c (sorry I need more effort to review)

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de

faire

Quoted 7 lines

le pas!
http://reg.tiscali.be/default.asp?lg=fr

Quoted 8 lines

Attachment: drivers-video-fbcon.diff

Attachment: fs-readdir.diff

Attachment: kernel-sysctl.diff

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr

author
#12 lore raw

And finaly may be lib/crc32.c diff like:
--- linux-2.4.27-rc3-pa6mm/lib/crc32.c.Orig 2004-06-29 11:29:31.000000000
+0200
+++ linux-2.4.27-rc3-pa6mm/lib/crc32.c 2004-07-30 17:17:56.143095488 +0200
@@ -99,7 +99,9 @@
/* Align it */ if(unlikely(((long)b)&3 && len)){
do {
- DO_CRC(*((u8 *)b)++);
+ u8 *pb = (u8 *)b;
+ DO_CRC(*pb++);
+ b = (u32 *)pb;
} while ((--len) && ((long)b)&3 );
}
if(likely(len >= 4)){
@@ -120,7 +122,9 @@
/* And the last few bytes */ if(len){
do {
- DO_CRC(*((u8 *)b)++);
+ u8 *pb = (u8 *)b;
+ DO_CRC(*pb++);
+ b = (u32 *)pb;
} while (--len);
}

@@ -200,7 +204,9 @@
/* Align it */ if(unlikely(((long)b)&3 && len)){
do {
- DO_CRC(*((u8 *)b)++);
+ u8 *pb = (u8 *)b;
+ DO_CRC(*pb++);
+ b = (u32 *)pb;
} while ((--len) && ((long)b)&3 );
}
if(likely(len >= 4)){
@@ -221,7 +227,9 @@
/* And the last few bytes */ if(len){
do {
- DO_CRC(*((u8 *)b)++);
+ u8 *pb = (u8 *)b;
+ DO_CRC(*pb++);
+ b = (u32 *)pb;
} while (--len);
}
return __be32_to_cpu(crc);
=========><=========

(i prefer pb to avoid possible reading confusion with outer p parameter? and replace usage of (void *) by (u32 *) as the actual b type)

Thanks for additional attention,
Joel

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr

lib/crc32.c renamed from lib/crc32.c.Orig +12 -4
@@ -99,7 +99,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *pb = (u8 *)b;
+			DO_CRC(*pb++);
+			b = (u32 *)pb;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -120,7 +122,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *pb = (u8 *)b;
+			DO_CRC(*pb++);
+			b = (u32 *)pb;
 		} while (--len);
 	}
 
@@ -200,7 +204,9 @@
 	/* Align it */
 	if(unlikely(((long)b)&3 && len)){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *pb = (u8 *)b;
+			DO_CRC(*pb++);
+			b = (u32 *)pb;
 		} while ((--len) && ((long)b)&3 );
 	}
 	if(likely(len >= 4)){
@@ -221,7 +227,9 @@
 	/* And the last few bytes */
 	if(len){
 		do {
-			DO_CRC(*((u8 *)b)++);
+			u8 *pb = (u8 *)b;
+			DO_CRC(*pb++);
+			b = (u32 *)pb;
 		} while (--len);
 	}
 	return __be32_to_cpu(crc);
author
#13 lore raw
In reply to Marcelo Tosatti

Marcelo,

Thanks first for your attention.
Sorry also for delaying this works but I was a bit busy elsewhere.

Quoted 10 lines

-- Original Message --
Date: Tue, 27 Jul 2004 09:54:32 -0300
From: Marcelo Tosatti <[email protected]>
To: Joel Soete <[email protected]>
Cc: Daniel Jacobowitz <[email protected]>,
Vojtech Pavlik <[email protected]>,
Linux Kernel <[email protected]>
Subject: Re: Some cleanup patches for: '...lvalues is deprecated'

Quoted 13 lines
Quoted 12 lines · Joel Soete

Hello Daniel,

Quoted 9 lines
Quoted 5 lines

So just use

	buffer++;

here, and the intent is then clear.

Except C does not actually allow incrementing a void pointer, since void does not have a size.

That make better sense to me because aifair a void * was foreseen to

pass

Quoted 2 lines
Quoted 2 lines

any kind of type * as actual parameter?
(So as far as I understand, the aritthm pointer sould be dynamic for

the

Quoted 8 lines
Quoted 7 lines

best 'natural' behaviour?)

Quoted 5 lines

You can't do arithmetic on one either. GNU
C allows this as an extension.

It's actually this, IIRC:
buffer = ((char *) buffer) + 1;

Quoted 6 lines

Joel,

It seems the current code is working perfectly, generating correct asm code.

Could you come up with a good enough reason to do this cleanup (as far

as

Quoted 3 lines

I am concerned) in 2.4.x series?

My first attention was to cleanup some warning of type "use of cast expression as lvalue is deprecated"
with gcc-3.3.4. But afaik, right now, there are just few warning which didn't break the asm code.

I will try to come back asap with a better solution (at least I hope ;) )

Thanks again,
Joel

---------------------------------------------------------------------------
Tiscali ADSL LIGHT, 19,95 EUR/mois pendant 6 mois, c'est le moment de faire le pas!
http://reg.tiscali.be/default.asp?lg=fr