public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] embarassing typo
@ 2005-03-29 23:31 Vicente Feito
  2005-03-30  3:35 ` Måns Rullgård
  0 siblings, 1 reply; 11+ messages in thread
From: Vicente Feito @ 2005-03-29 23:31 UTC (permalink / raw)
  To: linux-kernel

As long as the variable doesn't get overflowed you would have a negation, you
shouldn't do dri_data[5] = ptr->dri * 0xff; if ptr->dri it's 255, but if
ptr->dri = 1 i.e. (like is set in zr36050_setup) then you would be getting
the negation, -1. the Direct rendering support is a flag afaik, so in this
case I believe is a worthy C obfuscated negation code :)
btw, are you sure about this patch?I would contact the maintainer first,
because and'ing that doesn't make much sense...
Disclaimer, all this is: AFAIK! :)

On Tuesday 29 March 2005 09:58 pm, you wrote:
> Måns Rullgård wrote:
> > "Ronald S. Bultje" <rbultje@ronald.bitfreak.net> 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[].  Looks like gcc isn't catching
> this problem.
>
> > 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
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH] embarassing typo
@ 2005-03-29 20:36 Ronald S. Bultje
  2005-03-29 21:02 ` Måns Rullgård
  0 siblings, 1 reply; 11+ messages in thread
From: Ronald S. Bultje @ 2005-03-29 20:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 436 bytes --]

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.

Signed-off-by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>

Thanks,

Ronald

-- 
Ronald S. Bultje <rbultje@ronald.bitfreak.net>

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 577 bytes --]

? .tmp_versions
Index: zr36050.c
===================================================================
RCS file: /cvsroot/mjpeg/driver-zoran/zr36050.c,v
retrieving revision 1.2
diff -u -r1.2 zr36050.c
--- 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;
 	return zr36050_pushit(ptr, ZR050_DRI_IDX, 6, dri_data);
 }
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-03-31  4:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-29 23:31 [PATCH] embarassing typo Vicente Feito
2005-03-30  3:35 ` Måns Rullgård
  -- strict thread matches above, loose matches on Subject: below --
2005-03-29 20:36 Ronald S. Bultje
2005-03-29 21:02 ` Måns Rullgård
2005-03-29 21:58   ` Michael Tokarev
2005-03-30  1:40     ` Dmitry Torokhov
2005-03-30  5:53       ` Gene Heskett
2005-03-30 23:38         ` John Pearson
2005-03-31  4:16           ` Gene Heskett
2005-03-30  2:07     ` Måns Rullgård
2005-03-30  3:34       ` Phil Howard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox