* [PATCH] (1/22) lvalues abuse in dmasound
@ 2005-08-25 5:23 Al Viro
2005-08-25 9:04 ` Roman Zippel
0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2005-08-25 5:23 UTC (permalink / raw)
To: geert, torvalds; +Cc: linux-kernel, linux-m68k
result of typecast is not an lvalue. Part of those are fixed in m68k
CVS.
Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
----
diff -urN RC13-rc7/sound/oss/dmasound/dmasound_atari.c RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_atari.c
--- RC13-rc7/sound/oss/dmasound/dmasound_atari.c 2005-06-17 15:48:29.000000000 -0400
+++ RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_atari.c 2005-08-25 00:54:04.000000000 -0400
@@ -217,8 +217,9 @@
used = count*2;
while (count > 0) {
u_short data;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
*p++ = data ^ 0x8080;
count--;
}
@@ -240,8 +241,9 @@
used = count*2;
while (count > 0) {
u_short data;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
*p++ = data;
*p++ = data;
count--;
@@ -271,8 +273,9 @@
used = count*2;
while (count > 0) {
u_short data;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data ^= 0x8000;
*p++ = data;
*p++ = data;
@@ -285,8 +288,9 @@
used = count*4;
while (count > 0) {
u_long data;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
*p++ = data ^ 0x80008000;
count--;
}
@@ -309,8 +313,9 @@
used = count*2;
while (count > 0) {
u_short data;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data = le2be16(data);
*p++ = data;
*p++ = data;
@@ -323,8 +328,9 @@
used = count*4;
while (count > 0) {
u_long data;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
data = le2be16dbl(data);
*p++ = data;
count--;
@@ -348,8 +354,9 @@
used = count*2;
while (count > 0) {
u_short data;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data = le2be16(data) ^ 0x8000;
*p++ = data;
*p++ = data;
@@ -361,8 +368,9 @@
used = count;
while (count > 0) {
u_long data;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
data = le2be16dbl(data) ^ 0x80008000;
*p++ = data;
count--;
@@ -470,8 +478,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
userCount -= 2;
bal += hSpeed;
}
@@ -524,8 +533,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data ^= 0x8080;
userCount -= 2;
bal += hSpeed;
@@ -561,8 +571,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
userCount -= 2;
bal += hSpeed;
}
@@ -579,8 +590,9 @@
if (bal < 0) {
if (userCount < 4)
break;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
userCount -= 4;
bal += hSpeed;
}
@@ -615,8 +627,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data ^= 0x8000;
userCount -= 2;
bal += hSpeed;
@@ -634,8 +647,9 @@
if (bal < 0) {
if (userCount < 4)
break;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
data ^= 0x80008000;
userCount -= 4;
bal += hSpeed;
@@ -671,8 +685,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data = le2be16(data);
userCount -= 2;
bal += hSpeed;
@@ -690,8 +705,9 @@
if (bal < 0) {
if (userCount < 4)
break;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
data = le2be16dbl(data);
userCount -= 4;
bal += hSpeed;
@@ -727,8 +743,9 @@
if (bal < 0) {
if (userCount < 2)
break;
- if (get_user(data, ((u_short *)userPtr)++))
+ if (get_user(data, (u_short *)userPtr))
return -EFAULT;
+ userPtr += 2;
data = le2be16(data) ^ 0x8000;
userCount -= 2;
bal += hSpeed;
@@ -746,8 +763,9 @@
if (bal < 0) {
if (userCount < 4)
break;
- if (get_user(data, ((u_int *)userPtr)++))
+ if (get_user(data, (u_int *)userPtr))
return -EFAULT;
+ userPtr += 4;
data = le2be16dbl(data) ^ 0x80008000;
userCount -= 4;
bal += hSpeed;
diff -urN RC13-rc7/sound/oss/dmasound/dmasound_paula.c RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_paula.c
--- RC13-rc7/sound/oss/dmasound/dmasound_paula.c 2005-06-17 15:48:29.000000000 -0400
+++ RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_paula.c 2005-08-25 00:54:04.000000000 -0400
@@ -253,8 +253,9 @@
count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
used = count*2; \
while (count > 0) { \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, (u_short *)userPtr)) \
return -EFAULT; \
+ userPtr += 2; \
data = convsample(data); \
*high++ = data>>8; \
*low++ = (data>>2) & 0x3f; \
@@ -268,13 +269,15 @@
count = min_t(size_t, userCount, frameLeft)>>2 & ~1; \
used = count*4; \
while (count > 0) { \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, (u_short *)userPtr)) \
return -EFAULT; \
+ userPtr += 2; \
data = convsample(data); \
*lefth++ = data>>8; \
*leftl++ = (data>>2) & 0x3f; \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, (u_short *)userPtr)) \
return -EFAULT; \
+ userPtr += 2; \
data = convsample(data); \
*righth++ = data>>8; \
*rightl++ = (data>>2) & 0x3f; \
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] (1/22) lvalues abuse in dmasound
2005-08-25 5:23 [PATCH] (1/22) lvalues abuse in dmasound Al Viro
@ 2005-08-25 9:04 ` Roman Zippel
0 siblings, 0 replies; 2+ messages in thread
From: Roman Zippel @ 2005-08-25 9:04 UTC (permalink / raw)
To: Al Viro; +Cc: geert, torvalds, linux-kernel, linux-m68k
Hi,
On Thu, 25 Aug 2005, Al Viro wrote:
> diff -urN RC13-rc7/sound/oss/dmasound/dmasound_paula.c RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_paula.c
> --- RC13-rc7/sound/oss/dmasound/dmasound_paula.c 2005-06-17 15:48:29.000000000 -0400
> +++ RC13-rc7-dmasound-lvalues/sound/oss/dmasound/dmasound_paula.c 2005-08-25 00:54:04.000000000 -0400
> @@ -253,8 +253,9 @@
> count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
> used = count*2; \
> while (count > 0) { \
> - if (get_user(data, ((u_short *)userPtr)++)) \
> + if (get_user(data, (u_short *)userPtr)) \
> return -EFAULT; \
> + userPtr += 2; \
> data = convsample(data); \
> *high++ = data>>8; \
> *low++ = (data>>2) & 0x3f; \
> @@ -268,13 +269,15 @@
> count = min_t(size_t, userCount, frameLeft)>>2 & ~1; \
> used = count*4; \
> while (count > 0) { \
> - if (get_user(data, ((u_short *)userPtr)++)) \
> + if (get_user(data, (u_short *)userPtr)) \
> return -EFAULT; \
> + userPtr += 2; \
> data = convsample(data); \
> *lefth++ = data>>8; \
> *leftl++ = (data>>2) & 0x3f; \
> - if (get_user(data, ((u_short *)userPtr)++)) \
> + if (get_user(data, (u_short *)userPtr)) \
> return -EFAULT; \
> + userPtr += 2; \
> data = convsample(data); \
> *righth++ = data>>8; \
> *rightl++ = (data>>2) & 0x3f; \
Please replace this with the patch from CVS:
Index: sound/oss/dmasound/dmasound_paula.c
===================================================================
RCS file: /home/linux-m68k/cvsroot/linux/sound/oss/dmasound/dmasound_paula.c,v
retrieving revision 1.1.1.7
retrieving revision 1.6
diff -u -p -r1.1.1.7 -r1.6
--- sound/oss/dmasound/dmasound_paula.c 15 Aug 2004 14:21:28 -0000 1.1.1.7
+++ sound/oss/dmasound/dmasound_paula.c 29 May 2005 18:01:55 -0000 1.6
@@ -244,6 +244,7 @@ static ssize_t funcname(const u_char *us
u_char frame[], ssize_t *frameUsed, \
ssize_t frameLeft) \
{ \
+ const u_short *ptr = (const u_short *)userPtr; \
ssize_t count, used; \
u_short data; \
\
@@ -253,7 +254,7 @@ static ssize_t funcname(const u_char *us
count = min_t(size_t, userCount, frameLeft)>>1 & ~1; \
used = count*2; \
while (count > 0) { \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, ptr++)) \
return -EFAULT; \
data = convsample(data); \
*high++ = data>>8; \
@@ -268,12 +269,12 @@ static ssize_t funcname(const u_char *us
count = min_t(size_t, userCount, frameLeft)>>2 & ~1; \
used = count*4; \
while (count > 0) { \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, ptr++)) \
return -EFAULT; \
data = convsample(data); \
*lefth++ = data>>8; \
*leftl++ = (data>>2) & 0x3f; \
- if (get_user(data, ((u_short *)userPtr)++)) \
+ if (get_user(data, ptr++)) \
return -EFAULT; \
data = convsample(data); \
*righth++ = data>>8; \
bye, Roman
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-08-25 9:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-25 5:23 [PATCH] (1/22) lvalues abuse in dmasound Al Viro
2005-08-25 9:04 ` Roman Zippel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®