Skip to contentSkip to conversation

fbcon: incorrect use of "&&" instead of "&"

PATCH-2.4 Willy Tarreau 2 participants 3 messages Nov 25, 2006 – Nov 26, 2006 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Hi Geert,

I'm about to merge this in 2.4. Do you have any objection ?

Thanks,
Willy

Quoted 1 line

From c969fc8009aeb748368319cec463ae2516f6fb17 Mon Sep 17 00:00:00 2001

From: Willy Tarreau <[email protected]>
Date: Sat, 25 Nov 2006 21:54:10 +0100
Subject: [PATCH] fbcon: incorrect use of "&&" instead of "&"

The use of "&&" in the following statement causes unexpected cases to be matched since __SCROLL_YMASK = 0x0f :

    switch (p->scrollmode && __SCROLL_YMASK)
        case __SCROLL_YWRAP: ...  /* 0x02 */
        case __SCROLL_YPAN: ...   /* 0x01 */

The YWRAP case can never be matched and the YPAN case may be matched by mistake. Obvious fix is to replace && with &. This bug is not present in 2.6.

---
 drivers/video/fbcon.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fbcon.c +1 -1
index 0fb40c5..1f66819 100644
@@ -2102,7 +2102,7 @@ static int fbcon_scrolldelta(struct vc_d
 
     offset = p->yscroll-scrollback_current;
     limit = p->vrows;
-    switch (p->scrollmode && __SCROLL_YMASK) {
+    switch (p->scrollmode & __SCROLL_YMASK) {
 	case __SCROLL_YWRAP:
 	    p->var.vmode |= FB_VMODE_YWRAP;
 	    break;
Signature · 1 line
1.4.2.4
#1 lore raw
Quoted 1 line · Willy Tarreau

I'm about to merge this in 2.4. Do you have any objection ?

No.

Quoted 36 lines
Quoted 1 line

From c969fc8009aeb748368319cec463ae2516f6fb17 Mon Sep 17 00:00:00 2001

From: Willy Tarreau <[email protected]>
Date: Sat, 25 Nov 2006 21:54:10 +0100
Subject: [PATCH] fbcon: incorrect use of "&&" instead of "&"

The use of "&&" in the following statement causes unexpected cases to be matched since __SCROLL_YMASK = 0x0f :

    switch (p->scrollmode && __SCROLL_YMASK)
        case __SCROLL_YWRAP: ...  /* 0x02 */
        case __SCROLL_YPAN: ...   /* 0x01 */

The YWRAP case can never be matched and the YPAN case may be matched by mistake. Obvious fix is to replace && with &. This bug is not present in 2.6.

---
 drivers/video/fbcon.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/video/fbcon.c +1 -1
index 0fb40c5..1f66819 100644
@@ -2102,7 +2102,7 @@ static int fbcon_scrolldelta(struct vc_d
 
     offset = p->yscroll-scrollback_current;
     limit = p->vrows;
-    switch (p->scrollmode && __SCROLL_YMASK) {
+    switch (p->scrollmode & __SCROLL_YMASK) {
 	case __SCROLL_YWRAP:
 	    p->var.vmode |= FB_VMODE_YWRAP;
 	    break;
Signature · 1 line
1.4.2.4

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds