embarassing typo
PATCH 1/1 embarassing typo
Hi Andrew,
for some unknown reason, I suddenly found the attached typo. It doesn't cause anything bad (at least not on my computer according to some tests), but is still very much so embarassing, so please apply to the kernel tree. Who knows, maybe it fixes some obscure unfixeable bug for some people.
Thanks,
Ronald
Signature · 1 line
Ronald S. Bultje <[email protected]>
? .tmp_versions
Index: zr36050.c
===================================================================
RCS file: /cvsroot/mjpeg/driver-zoran/zr36050.c,v
retrieving revision 1.2
drivers/media/video/zr36050.c renamed from drivers/media/video/zr36050.c.old +1 -1
@@ -419,7 +419,7 @@ dri_data[2 ] =0x00 ; dri_data[3 ] =0x04 ; dri_data[4 ] = ptr->dri >>8 ; - dri_data[5 ] = ptr->dri *0xff ; + dri_data[5 ] = ptr->dri &0xff ;return zr36050_pushit (ptr,ZR050_DRI_IDX ,6 , dri_data); }
drivers/media/video/zr36050.c line 422
Quoted 8 lines · Ronald S. Bultje
drivers/media/video/zr36050.c renamed from drivers/media/video/zr36050.c.old +1
-1@@ -419,7 +419,7 @@ dri_data[2 ] =0x00 ; dri_data[3 ] =0x04 ; dri_data[4 ] = ptr->dri >>8 ; - dri_data[5 ] = ptr->dri *0xff ; + dri_data[5 ] = ptr->dri &0xff ;
Hey, that's a nice obfuscation of a simple negation.
BTW, when assigning to a char type, is the masking really necessary at all? I can't see that it should make a difference. Am I missing something subtle?
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 12 lines · Måns Rullgård
drivers/media/video/zr36050.c line 422
Quoted 8 lines · Ronald S. Bultje
drivers/media/video/zr36050.c renamed from drivers/media/video/zr36050.c.old +1
-1@@ -419,7 +419,7 @@ dri_data[2 ] =0x00 ; dri_data[3 ] =0x04 ; dri_data[4 ] = ptr->dri >>8 ; - dri_data[5 ] = ptr->dri *0xff ; + dri_data[5 ] = ptr->dri &0xff ;Hey, that's a nice obfuscation of a simple negation.
It's not a negation. This statement always assigns zero to dri_data[5] if dri_data is char[]. Looks like gcc isn't catching this problem.
Quoted 3 lines
BTW, when assigning to a char type, is the masking really necessary at all? I can't see that it should make a difference. Am I missing something subtle?
Well, it's a matter of readability mostly. For now at least, when char is always 8 bytes...
/mjt
Quoted 2 lines · Michael Tokarev
Well, it's a matter of readability mostly. For now at least, when char is always 8 bytes...
Wow, that's one huge char you have there ;)
Signature · 1 line
Dmitry
Quoted 5 lines · Dmitry Torokhov
Quoted 2 lines · Michael Tokarev
Well, it's a matter of readability mostly. For now at least, when char is always 8 bytes...
Wow, that's one huge char you have there ;)
Yeah, I was gonna ask what language is so complex as to need an 8 byte char?
Certainly not an earthly one I'd think ;)
Signature · 8 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) 99.34% setiathome rank, not too shabby for a WV hillbilly Yahoo.com and AOL/TW attorneys please note, additions to the above message by Gene Heskett are: Copyright 2005 by Maurice Eugene Heskett, all rights reserved.
On Wed, Mar 30, 2005 at 12:53:28AM -0500, Gene Heskett wrote
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Michael Tokarev
Quoted 2 lines
Well, it's a matter of readability mostly. ?For now at least, when char is always 8 bytes...
Quoted 7 lines
Quoted 1 line
Wow, that's one huge char you have there ;)
Yeah, I was gonna ask what language is so complex as to need an 8 byte char?
Certainly not an earthly one I'd think ;)
Might come in handy for Perl 7 Regular Expression syntax...
John.
Signature · 20 lines
Voice: +61 8 8202 9040 Email: [email protected] Oasis Systems Pty Ltd 288 Glen Osmond Road Fullarton, South Australia 5063 Ph: + 61 8 82029000 Fax: +61 8 82029001 CAUTION: This email and any attachments may contain information that is confidential and subject to copyright. If you are not the intended recipient, you must not read, use, disseminate, distribute or copy this email or any attachments. If you have received this email in error, please notify the sender immediately by reply email and erase this email and any attachments. DISCLAIMER: OASIS Systems uses virus-scanning technology but accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus.
Quoted 7 lines · John Pearson
On Wed, Mar 30, 2005 at 12:53:28AM -0500, Gene Heskett wrote
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Michael Tokarev
Quoted 2 lines
Well, it's a matter of readability mostly. ?For now at least, when char is always 8 bytes...
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Wow, that's one huge char you have there ;)
Yeah, I was gonna ask what language is so complex as to need an 8 byte char?
Certainly not an earthly one I'd think ;)
Might come in handy for Perl 7 Regular Expression syntax...
Humm, yes, perl. I'd forgotten that. Would an 8 byte char be enough in that case?
Quoted 1 line
John.
Signature · 8 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) 99.34% setiathome rank, not too shabby for a WV hillbilly Yahoo.com and AOL/TW attorneys please note, additions to the above message by Gene Heskett are: Copyright 2005 by Maurice Eugene Heskett, all rights reserved.
Quoted 13 lines · Michael Tokarev
Quoted 11 lines · Måns Rullgård
drivers/media/video/zr36050.c line 422
Quoted 8 lines · Ronald S. Bultje
drivers/media/video/zr36050.c renamed from drivers/media/video/zr36050.c.old +1
-1@@ -419,7 +419,7 @@ dri_data[2 ] =0x00 ; dri_data[3 ] =0x04 ; dri_data[4 ] = ptr->dri >>8 ; - dri_data[5 ] = ptr->dri *0xff ; + dri_data[5 ] = ptr->dri &0xff ;Hey, that's a nice obfuscation of a simple negation.
Quoted 2 lines
It's not a negation. This statement always assigns zero to dri_data[5] if
dri_datais char[].
Sure about that?
__u16 i;
char c;
i = 1; c = i * 255; /* c = 255 = -1 */
i = 2; c = i * 255; /* c = 510 & 0xff = 254 = -2 */
...
Looks like negation to me.
Signature · 2 lines
Måns Rullgård [email protected]
On Wed, Mar 30, 2005 at 04:07:39AM +0200, M?ns Rullg?rd wrote:
| Michael Tokarev <[email protected]> writes: | | > M?ns Rullg?rd wrote: | >> "Ronald S. Bultje" <[email protected]> writes: | >> | >>>--- linux-2.6.5/drivers/media/video/zr36050.c.old 16 Sep 2004 22:53:27 -0000 1.2 | >>>+++ linux-2.6.5/drivers/media/video/zr36050.c 29 Mar 2005 20:30:23 -0000 | >>>@@ -419,7 +419,7 @@ | >>> dri_data[2] = 0x00; | >>> dri_data[3] = 0x04; | >>> dri_data[4] = ptr->dri >> 8; | >>>- dri_data[5] = ptr->dri * 0xff; | >>>+ dri_data[5] = ptr->dri & 0xff; | >> Hey, that's a nice obfuscation of a simple negation. | > | > It's not a negation. This statement always assigns zero to | > dri_data[5] if dri_data is char[]. | | Sure about that? | | __u16 i; | char c; | i = 1; c = i * 255; /* c = 255 = -1 */ | i = 2; c = i * 255; /* c = 510 & 0xff = 254 = -2 */ | ... | | Looks like negation to me.
Sure it's negation because 255 _is_ 256 - 1. Basic finite math.
( x * 256 ) mod 256 == 0
( ( x * 256 ) - ( x * 1 ) ) mod 256 == - ( x * 1 )
( x * ( 256 - 1 ) ) mod 256 == - ( x * 1 ) ( x * 255 ) mod 256 == - ( x * 1 ) ( x * 255 ) mod 256 == - x
Now what I am interested in is if gcc optimized it to a faster negation or subtraction instruction.
Signature · 4 lines
----------------------------------------------------------------------------- | Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ | | (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ | -----------------------------------------------------------------------------